ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
January 2009
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
30 participants
755 discussions
Start a n
N
ew thread
[cwittich] 39223: sync cryptui with wine 1.1.14
by cwittich@svn.reactos.org
Author: cwittich Date: Sat Jan 31 05:47:29 2009 New Revision: 39223 URL:
http://svn.reactos.org/svn/reactos?rev=39223&view=rev
Log: sync cryptui with wine 1.1.14 Modified: trunk/reactos/dll/win32/cryptui/cryptui.spec trunk/reactos/dll/win32/cryptui/cryptui_En.rc trunk/reactos/dll/win32/cryptui/cryptuires.h trunk/reactos/dll/win32/cryptui/main.c trunk/reactos/include/psdk/cryptuiapi.h Modified: trunk/reactos/dll/win32/cryptui/cryptui.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/cryptui/cryptui.…
============================================================================== --- trunk/reactos/dll/win32/cryptui/cryptui.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/cryptui/cryptui.spec [iso-8859-1] Sat Jan 31 05:47:29 2009 @@ -31,7 +31,7 @@ 31 stub CryptUIWizCertRequest 32 stub CryptUIWizCreateCertRequestNoDS 33 stub CryptUIWizDigitalSign -34 stub CryptUIWizExport +34 stdcall CryptUIWizExport(long ptr wstr ptr ptr) 35 stub CryptUIWizFreeCertRequestNoDS 36 stub CryptUIWizFreeDigitalSignContext 37 stdcall CryptUIWizImport(long ptr wstr ptr ptr) Modified: trunk/reactos/dll/win32/cryptui/cryptui_En.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/cryptui/cryptui_…
============================================================================== --- trunk/reactos/dll/win32/cryptui/cryptui_En.rc [iso-8859-1] (original) +++ trunk/reactos/dll/win32/cryptui/cryptui_En.rc [iso-8859-1] Sat Jan 31 05:47:29 2009 @@ -141,6 +141,26 @@ IDS_PURPOSE_CA_EXCHANGE "Private Key Archival" IDS_PURPOSE_KEY_RECOVERY_AGENT "Key Recovery Agent" IDS_PURPOSE_DS_EMAIL_REPLICATION "Directory Service Email Replication" + IDS_EXPORT_WIZARD "Certificate Export Wizard" + IDS_EXPORT_FORMAT_TITLE "Export Format" + IDS_EXPORT_FORMAT_SUBTITLE "Choose the format in which the content will be saved." + IDS_EXPORT_FILE_TITLE "Export Filename" + IDS_EXPORT_FILE_SUBTITLE "Specify the name of the file in which the content will be saved." + IDS_EXPORT_FILE_EXISTS "The specified file already exists. Do you want to replace it?" + IDS_EXPORT_FILTER_CERT "DER-Encoded Binary X.509 (*.cer)" + IDS_EXPORT_FILTER_BASE64_CERT "Base64-Encoded X.509 (*.cer)" + IDS_EXPORT_FILTER_CRL "Certificate Revocation List (*.crl)" + IDS_EXPORT_FILTER_CTL "Certificate Trust List (*.stl)" + IDS_EXPORT_FILTER_CMS "CMS/PKCS #7 Messages (*.p7b)" + IDS_EXPORT_FILTER_PFX "Personal Information Exchange (*.pfx)" + IDS_EXPORT_FILTER_SERIALIZED_CERT_STORE "Serialized Certificate Store (*.sst)" + IDS_EXPORT_FORMAT "File Format" + IDS_EXPORT_INCLUDE_CHAIN "Include all certificates in certificate path" + IDS_EXPORT_KEYS "Export keys" + IDS_YES "Yes" + IDS_NO "No" + IDS_EXPORT_SUCCEEDED "The export was successful." + IDS_EXPORT_FAILED "The export failed." } IDD_GENERAL DIALOG DISCARDABLE 0, 0, 255, 236 @@ -346,3 +366,66 @@ PUSHBUTTON "OK", IDOK, 132,155,51,14, BS_DEFPUSHBUTTON PUSHBUTTON "Cancel", IDCANCEL, 190,155,51,14 END + +IDD_EXPORT_WELCOME DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificate Export Wizard" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Welcome to the Certificate Export Wizard", IDC_EXPORT_TITLE, + 115,1,195,40 + LTEXT "This wizard helps you export certificates, certificate revocation lists, and certificate trust lists from a certificate store to a file.", + -1, 115,33,195,16 + LTEXT "A certificate can be used to identify you or the computer with which you are communicating. It can also be used for authentication, and to sign messages. Certificate stores are collections of certificates, certificate revocation lists, and certificate trust lists.", + -1, 115,56,195,40 + LTEXT "To continue, click Next.", + -1, 115,103,195,8 +END + +IDD_EXPORT_FORMAT DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificate Export Wizard" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Select the format you want to use:", -1, 21,1,195,10 + AUTORADIOBUTTON "&DER-encoded X.509 (.cer)", + IDC_EXPORT_FORMAT_DER, 31,18,200,12, BS_AUTORADIOBUTTON|WS_TABSTOP + AUTORADIOBUTTON "Ba&se64-encoded X.509 (.cer):", + IDC_EXPORT_FORMAT_BASE64, 31,30,200,12, BS_AUTORADIOBUTTON + AUTORADIOBUTTON "&Cryptographic Message Syntax Standard/PKCS #7 Message (.p7b)", + IDC_EXPORT_FORMAT_CMS, 31,42,200,12, BS_AUTORADIOBUTTON + CHECKBOX "&Include all certificates in the certification path if possible", + IDC_EXPORT_CMS_INCLUDE_CHAIN, 44,57,200,8, BS_AUTOCHECKBOX|WS_TABSTOP|WS_DISABLED + AUTORADIOBUTTON "&Personal Information Exchange/PKCS #12 (.pfx)", + IDC_EXPORT_FORMAT_PFX, 31,72,200,12, BS_AUTORADIOBUTTON|WS_DISABLED + CHECKBOX "Incl&ude all certificates in the certification path if possible", + IDC_EXPORT_PFX_INCLUDE_CHAIN, 44,87,200,8, BS_AUTOCHECKBOX|WS_TABSTOP|WS_DISABLED + CHECKBOX "&Enable strong encryption", + IDC_EXPORT_PFX_STRONG_ENCRYPTION, 44,102,200,8, + BS_AUTOCHECKBOX|WS_TABSTOP|WS_DISABLED + CHECKBOX "Delete the private &key if the export is successful", + IDC_EXPORT_PFX_DELETE_PRIVATE_KEY, 44,117,200,8, + BS_AUTOCHECKBOX|WS_TABSTOP|WS_DISABLED +END + +IDD_EXPORT_FILE DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificate Export Wizard" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "&File name:", -1, 21,1,195,10 + EDITTEXT IDC_EXPORT_FILENAME, 21,11,208,14, ES_AUTOHSCROLL|WS_TABSTOP + PUSHBUTTON "B&rowse...", IDC_EXPORT_BROWSE_FILE, 236,11,60,14 +END + +IDD_EXPORT_FINISH DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificate Export Wizard" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Completing the Certificate Export Wizard", IDC_EXPORT_TITLE, + 115,1,195,40 + LTEXT "You have successfully completed the Certificate Export Wizard.", + -1, 115,33,195,24 + LTEXT "You have specified the following settings:", + -1, 115,57,195,12 + CONTROL "", IDC_EXPORT_SETTINGS, "SysListView32", + LVS_REPORT|LVS_NOCOLUMNHEADER|LVS_SINGLESEL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER, + 115,67,174,100 +END Modified: trunk/reactos/dll/win32/cryptui/cryptuires.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/cryptui/cryptuir…
============================================================================== --- trunk/reactos/dll/win32/cryptui/cryptuires.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/cryptui/cryptuires.h [iso-8859-1] Sat Jan 31 05:47:29 2009 @@ -140,6 +140,27 @@ #define IDS_PURPOSE_KEY_RECOVERY_AGENT 1124 #define IDS_PURPOSE_DS_EMAIL_REPLICATION 1125 +#define IDS_EXPORT_WIZARD 1200 +#define IDS_EXPORT_FORMAT_TITLE 1201 +#define IDS_EXPORT_FORMAT_SUBTITLE 1202 +#define IDS_EXPORT_FILE_TITLE 1203 +#define IDS_EXPORT_FILE_SUBTITLE 1204 +#define IDS_EXPORT_FILE_EXISTS 1205 +#define IDS_EXPORT_FILTER_CERT 1206 +#define IDS_EXPORT_FILTER_BASE64_CERT 1207 +#define IDS_EXPORT_FILTER_CRL 1208 +#define IDS_EXPORT_FILTER_CTL 1209 +#define IDS_EXPORT_FILTER_CMS 1210 +#define IDS_EXPORT_FILTER_PFX 1211 +#define IDS_EXPORT_FILTER_SERIALIZED_CERT_STORE 1212 +#define IDS_EXPORT_FORMAT 1213 +#define IDS_EXPORT_INCLUDE_CHAIN 1214 +#define IDS_EXPORT_KEYS 1215 +#define IDS_YES 1216 +#define IDS_NO 1217 +#define IDS_EXPORT_SUCCEEDED 1218 +#define IDS_EXPORT_FAILED 1219 + #define IDD_GENERAL 100 #define IDD_DETAIL 101 #define IDD_HIERARCHY 102 @@ -153,6 +174,10 @@ #define IDD_IMPORT_FINISH 110 #define IDD_CERT_MGR 111 #define IDD_CERT_MGR_ADVANCED 112 +#define IDD_EXPORT_WELCOME 113 +#define IDD_EXPORT_FORMAT 114 +#define IDD_EXPORT_FILE 115 +#define IDD_EXPORT_FINISH 116 #define IDB_SMALL_ICONS 200 #define IDB_CERT 201 @@ -216,4 +241,17 @@ #define IDC_MGR_PURPOSES 2807 #define IDC_MGR_VIEW 2808 +#define IDC_EXPORT_TITLE 2900 +#define IDC_EXPORT_FORMAT_DER 2901 +#define IDC_EXPORT_FORMAT_BASE64 2902 +#define IDC_EXPORT_FORMAT_CMS 2903 +#define IDC_EXPORT_FORMAT_PFX 2904 +#define IDC_EXPORT_CMS_INCLUDE_CHAIN 2905 +#define IDC_EXPORT_PFX_INCLUDE_CHAIN 2906 +#define IDC_EXPORT_PFX_STRONG_ENCRYPTION 2907 +#define IDC_EXPORT_PFX_DELETE_PRIVATE_KEY 2908 +#define IDC_EXPORT_FILENAME 2909 +#define IDC_EXPORT_BROWSE_FILE 2910 +#define IDC_EXPORT_SETTINGS 2911 + #endif /* ndef __CRYPTUIRES_H_ */ Modified: trunk/reactos/dll/win32/cryptui/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/cryptui/main.c?r…
============================================================================== --- trunk/reactos/dll/win32/cryptui/main.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/cryptui/main.c [iso-8859-1] Sat Jan 31 05:47:29 2009 @@ -997,6 +997,67 @@ } } while (selection >= 0); cert_mgr_clear_cert_selection(hwnd); + } + } +} + +static void cert_mgr_do_export(HWND hwnd) +{ + HWND lv = GetDlgItem(hwnd, IDC_MGR_CERTS); + int selectionCount = SendMessageW(lv, LVM_GETSELECTEDCOUNT, 0, 0); + + if (selectionCount == 1) + { + int selection = SendMessageW(lv, LVM_GETNEXTITEM, -1, + LVNI_SELECTED); + + if (selection >= 0) + { + PCCERT_CONTEXT cert = cert_mgr_index_to_cert(hwnd, selection); + + if (cert) + { + CRYPTUI_WIZ_EXPORT_INFO info; + + info.dwSize = sizeof(info); + info.pwszExportFileName = NULL; + info.dwSubjectChoice = CRYPTUI_WIZ_EXPORT_CERT_CONTEXT; + info.u.pCertContext = cert; + info.cStores = 0; + CryptUIWizExport(0, hwnd, NULL, &info, NULL); + } + } + } + else if (selectionCount > 1) + { + HCERTSTORE store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, + CERT_STORE_CREATE_NEW_FLAG, NULL); + + if (store) + { + CRYPTUI_WIZ_EXPORT_INFO info; + int selection = -1; + + info.dwSize = sizeof(info); + info.pwszExportFileName = NULL; + info.dwSubjectChoice = + CRYPTUI_WIZ_EXPORT_CERT_STORE_CERTIFICATES_ONLY; + info.u.hCertStore = store; + info.cStores = 0; + do { + selection = SendMessageW(lv, LVM_GETNEXTITEM, selection, + LVNI_SELECTED); + if (selection >= 0) + { + PCCERT_CONTEXT cert = cert_mgr_index_to_cert(hwnd, + selection); + + CertAddCertificateContextToStore(store, cert, + CERT_STORE_ADD_ALWAYS, NULL); + } + } while (selection >= 0); + CryptUIWizExport(0, hwnd, NULL, &info, NULL); + CertCloseStore(store, 0); } } } @@ -1134,6 +1195,9 @@ show_selected_cert(hwnd, selection); break; } + case IDC_MGR_EXPORT: + cert_mgr_do_export(hwnd); + break; case IDC_MGR_REMOVE: cert_mgr_do_remove(hwnd); break; @@ -3721,8 +3785,19 @@ switch (wp) { case IDC_EXPORT: - FIXME("call CryptUIWizExport\n"); - break; + { + HWND cb = GetDlgItem(hwnd, IDC_DETAIL_SELECT); + CRYPTUI_WIZ_EXPORT_INFO info; + + data = (struct detail_data *)SendMessageW(cb, CB_GETITEMDATA, 0, 0); + info.dwSize = sizeof(info); + info.pwszExportFileName = NULL; + info.dwSubjectChoice = CRYPTUI_WIZ_EXPORT_CERT_CONTEXT; + info.u.pCertContext = data->pCertViewInfo->pCertContext; + info.cStores = 0; + CryptUIWizExport(0, hwnd, NULL, &info, NULL); + break; + } case IDC_EDITPROPERTIES: { HWND cb = GetDlgItem(hwnd, IDC_DETAIL_SELECT); @@ -5288,7 +5363,7 @@ } else import_warning(data->dwFlags, hwnd, data->pwszWizardTitle, - IDS_IMPORT_SUCCEEDED); + IDS_IMPORT_FAILED); break; } } @@ -5435,3 +5510,995 @@ return ret; } + +struct ExportWizData +{ + HFONT titleFont; + DWORD dwFlags; + LPCWSTR pwszWizardTitle; + PCCRYPTUI_WIZ_EXPORT_INFO pExportInfo; + CRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO contextInfo; + LPWSTR fileName; + HANDLE file; + BOOL success; +}; + +static LRESULT CALLBACK export_welcome_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, + LPARAM lp) +{ + LRESULT ret = 0; + + switch (msg) + { + case WM_INITDIALOG: + { + struct ExportWizData *data; + PROPSHEETPAGEW *page = (PROPSHEETPAGEW *)lp; + WCHAR fontFace[MAX_STRING_LEN]; + HDC hDC = GetDC(hwnd); + int height; + + data = (struct ExportWizData *)page->lParam; + LoadStringW(hInstance, IDS_WIZARD_TITLE_FONT, fontFace, + sizeof(fontFace) / sizeof(fontFace[0])); + height = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72); + data->titleFont = CreateFontW(height, 0, 0, 0, FW_BOLD, 0, 0, 0, + DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, + DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, fontFace); + SendMessageW(GetDlgItem(hwnd, IDC_EXPORT_TITLE), WM_SETFONT, + (WPARAM)data->titleFont, TRUE); + ReleaseDC(hwnd, hDC); + break; + } + case WM_NOTIFY: + { + NMHDR *hdr = (NMHDR *)lp; + + switch (hdr->code) + { + case PSN_SETACTIVE: + PostMessageW(GetParent(hwnd), PSM_SETWIZBUTTONS, 0, PSWIZB_NEXT); + ret = TRUE; + break; + } + break; + } + } + return ret; +} + +static BOOL export_info_has_private_key(PCCRYPTUI_WIZ_EXPORT_INFO pExportInfo) +{ + BOOL ret = FALSE; + + if (pExportInfo->dwSubjectChoice == CRYPTUI_WIZ_EXPORT_CERT_CONTEXT) + { + DWORD size; + + /* If there's a CRYPT_KEY_PROV_INFO set for this cert, assume the + * cert has a private key. + */ + if (CertGetCertificateContextProperty(pExportInfo->u.pCertContext, + CERT_KEY_PROV_INFO_PROP_ID, NULL, &size)) + ret = TRUE; + } + return ret; +} + +static LRESULT CALLBACK export_format_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, + LPARAM lp) +{ + LRESULT ret = 0; + struct ExportWizData *data; + + switch (msg) + { + case WM_INITDIALOG: + { + PROPSHEETPAGEW *page = (PROPSHEETPAGEW *)lp; + int defaultFormatID; + BOOL hasPrivateKey; + + data = (struct ExportWizData *)page->lParam; + SetWindowLongPtrW(hwnd, DWLP_USER, (LPARAM)data); + hasPrivateKey = export_info_has_private_key(data->pExportInfo); + if (hasPrivateKey) + EnableWindow(GetDlgItem(hwnd, IDC_EXPORT_FORMAT_PFX), TRUE); + switch (data->contextInfo.dwExportFormat) + { + case CRYPTUI_WIZ_EXPORT_FORMAT_BASE64: + defaultFormatID = IDC_EXPORT_FORMAT_BASE64; + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7: + defaultFormatID = IDC_EXPORT_FORMAT_CMS; + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_PFX: + if (hasPrivateKey) + defaultFormatID = IDC_EXPORT_FORMAT_PFX; + else + defaultFormatID = IDC_EXPORT_FORMAT_DER; + break; + default: + defaultFormatID = IDC_EXPORT_FORMAT_DER; + } + SendMessageW(GetDlgItem(hwnd, defaultFormatID), BM_CLICK, 0, 0); + break; + } + case WM_NOTIFY: + { + NMHDR *hdr = (NMHDR *)lp; + + switch (hdr->code) + { + case PSN_SETACTIVE: + PostMessageW(GetParent(hwnd), PSM_SETWIZBUTTONS, 0, + PSWIZB_BACK | PSWIZB_NEXT); + ret = TRUE; + break; + case PSN_WIZNEXT: + { + data = (struct ExportWizData *)GetWindowLongPtrW(hwnd, DWLP_USER); + if (IsDlgButtonChecked(hwnd, IDC_EXPORT_FORMAT_DER)) + data->contextInfo.dwExportFormat = + CRYPTUI_WIZ_EXPORT_FORMAT_DER; + else if (IsDlgButtonChecked(hwnd, IDC_EXPORT_FORMAT_BASE64)) + data->contextInfo.dwExportFormat = + CRYPTUI_WIZ_EXPORT_FORMAT_BASE64; + else if (IsDlgButtonChecked(hwnd, IDC_EXPORT_FORMAT_CMS)) + { + data->contextInfo.dwExportFormat = + CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7; + if (IsDlgButtonChecked(hwnd, IDC_EXPORT_CMS_INCLUDE_CHAIN)) + data->contextInfo.fExportChain = + CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7; + } + else + { + data->contextInfo.dwExportFormat = + CRYPTUI_WIZ_EXPORT_FORMAT_PFX; + if (IsDlgButtonChecked(hwnd, IDC_EXPORT_PFX_INCLUDE_CHAIN)) + data->contextInfo.fExportChain = TRUE; + if (IsDlgButtonChecked(hwnd, IDC_EXPORT_PFX_STRONG_ENCRYPTION)) + data->contextInfo.fStrongEncryption = TRUE; + if (IsDlgButtonChecked(hwnd, IDC_EXPORT_PFX_DELETE_PRIVATE_KEY)) + data->contextInfo.fExportPrivateKeys = TRUE; + } + break; + } + } + break; + } + case WM_COMMAND: + switch (HIWORD(wp)) + { + case BN_CLICKED: + switch (LOWORD(wp)) + { + case IDC_EXPORT_FORMAT_DER: + case IDC_EXPORT_FORMAT_BASE64: + EnableWindow(GetDlgItem(hwnd, IDC_EXPORT_CMS_INCLUDE_CHAIN), + FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_EXPORT_PFX_INCLUDE_CHAIN), + FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_EXPORT_PFX_STRONG_ENCRYPTION), + FALSE); + EnableWindow(GetDlgItem(hwnd, + IDC_EXPORT_PFX_DELETE_PRIVATE_KEY), FALSE); + break; + case IDC_EXPORT_FORMAT_CMS: + EnableWindow(GetDlgItem(hwnd, IDC_EXPORT_CMS_INCLUDE_CHAIN), + TRUE); + break; + case IDC_EXPORT_FORMAT_PFX: + EnableWindow(GetDlgItem(hwnd, IDC_EXPORT_PFX_INCLUDE_CHAIN), + TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_EXPORT_PFX_STRONG_ENCRYPTION), + TRUE); + EnableWindow(GetDlgItem(hwnd, + IDC_EXPORT_PFX_DELETE_PRIVATE_KEY), TRUE); + break; + } + break; + } + break; + } + return ret; +} + +static LPWSTR export_append_extension(struct ExportWizData *data, + LPWSTR fileName) +{ + static const WCHAR cer[] = { '.','c','e','r',0 }; + static const WCHAR crl[] = { '.','c','r','l',0 }; + static const WCHAR ctl[] = { '.','c','t','l',0 }; + static const WCHAR p7b[] = { '.','p','7','b',0 }; + static const WCHAR pfx[] = { '.','p','f','x',0 }; + static const WCHAR sst[] = { '.','s','s','t',0 }; + LPCWSTR extension; + LPWSTR dot; + BOOL appendExtension; + + switch (data->contextInfo.dwExportFormat) + { + case CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7: + extension = p7b; + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_PFX: + extension = pfx; + break; + default: + switch (data->pExportInfo->dwSubjectChoice) + { + case CRYPTUI_WIZ_EXPORT_CRL_CONTEXT: + extension = crl; + break; + case CRYPTUI_WIZ_EXPORT_CTL_CONTEXT: + extension = ctl; + break; + case CRYPTUI_WIZ_EXPORT_CERT_STORE: + extension = sst; + break; + default: + extension = cer; + } + } + dot = strrchrW(fileName, '.'); + if (dot) + appendExtension = strcmpiW(dot, extension) != 0; + else + appendExtension = TRUE; + if (appendExtension) + { + fileName = HeapReAlloc(GetProcessHeap(), 0, fileName, + (strlenW(fileName) + strlenW(extension) + 1) * sizeof(WCHAR)); + if (fileName) + strcatW(fileName, extension); + } + return fileName; +} + +static BOOL export_validate_filename(HWND hwnd, struct ExportWizData *data, + LPCWSTR fileName) +{ + HANDLE file; + BOOL tryCreate = TRUE, forceCreate = FALSE, ret = FALSE; + + file = CreateFileW(fileName, GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + if (file != INVALID_HANDLE_VALUE) + { + WCHAR warning[MAX_STRING_LEN], title[MAX_STRING_LEN]; + LPCWSTR pTitle; + + if (data->pwszWizardTitle) + pTitle = data->pwszWizardTitle; + else + { + LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, + sizeof(title) / sizeof(title[0])); + pTitle = title; + } + LoadStringW(hInstance, IDS_EXPORT_FILE_EXISTS, warning, + sizeof(warning) / sizeof(warning[0])); + if (MessageBoxW(hwnd, warning, pTitle, MB_YESNO) == IDYES) + forceCreate = TRUE; + else + tryCreate = FALSE; + CloseHandle(file); + } + if (tryCreate) + { + file = CreateFileW(fileName, GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + forceCreate ? CREATE_ALWAYS : CREATE_NEW, + 0, NULL); + if (file != INVALID_HANDLE_VALUE) + { + data->file = file; + ret = TRUE; + } + else + { + WCHAR title[MAX_STRING_LEN], error[MAX_STRING_LEN]; + LPCWSTR pTitle; + LPWSTR msgBuf, fullError; + + if (data->pwszWizardTitle) + pTitle = data->pwszWizardTitle; + else + { + LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, + sizeof(title) / sizeof(title[0])); + pTitle = title; + } + LoadStringW(hInstance, IDS_IMPORT_OPEN_FAILED, error, + sizeof(error) / sizeof(error[0])); + FormatMessageW( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, + GetLastError(), 0, (LPWSTR) &msgBuf, 0, NULL); + fullError = HeapAlloc(GetProcessHeap(), 0, + (strlenW(error) + strlenW(fileName) + strlenW(msgBuf) + 3) + * sizeof(WCHAR)); + if (fullError) + { + LPWSTR ptr = fullError; + + strcpyW(ptr, error); + ptr += strlenW(error); + strcpyW(ptr, fileName); + ptr += strlenW(fileName); + *ptr++ = ':'; + *ptr++ = '\n'; + strcpyW(ptr, msgBuf); + MessageBoxW(hwnd, fullError, pTitle, MB_ICONERROR | MB_OK); + HeapFree(GetProcessHeap(), 0, fullError); + } + LocalFree(msgBuf); + } + } + return ret; +} + +static const WCHAR export_filter_cert[] = { '*','.','c','e','r',0 }; +static const WCHAR export_filter_crl[] = { '*','.','c','r','l',0 }; +static const WCHAR export_filter_ctl[] = { '*','.','s','t','l',0 }; +static const WCHAR export_filter_cms[] = { '*','.','p','7','b',0 }; +static const WCHAR export_filter_pfx[] = { '*','.','p','f','x',0 }; +static const WCHAR export_filter_sst[] = { '*','.','s','s','t',0 }; + +static WCHAR *make_export_file_filter(DWORD exportFormat, DWORD subjectChoice) +{ + int baseLen, allLen, totalLen = 2, baseID; + LPWSTR filter = NULL, baseFilter, all; + LPCWSTR filterStr; + + switch (exportFormat) + { + case CRYPTUI_WIZ_EXPORT_FORMAT_BASE64: + baseID = IDS_EXPORT_FILTER_BASE64_CERT; + filterStr = export_filter_cert; + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_PFX: + baseID = IDS_EXPORT_FILTER_PFX; + filterStr = export_filter_pfx; + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7: + baseID = IDS_EXPORT_FILTER_CMS; + filterStr = export_filter_cms; + break; + default: + switch (subjectChoice) + { + case CRYPTUI_WIZ_EXPORT_CRL_CONTEXT: + baseID = IDS_EXPORT_FILTER_CRL; + filterStr = export_filter_crl; + break; + case CRYPTUI_WIZ_EXPORT_CTL_CONTEXT: + baseID = IDS_EXPORT_FILTER_CTL; + filterStr = export_filter_ctl; + break; + case CRYPTUI_WIZ_EXPORT_CERT_STORE: + baseID = IDS_EXPORT_FILTER_SERIALIZED_CERT_STORE; + filterStr = export_filter_sst; + break; + default: + baseID = IDS_EXPORT_FILTER_CERT; + filterStr = export_filter_cert; + break; + } + } + baseLen = LoadStringW(hInstance, baseID, (LPWSTR)&baseFilter, 0); + totalLen += baseLen + strlenW(filterStr) + 2; + allLen = LoadStringW(hInstance, IDS_IMPORT_FILTER_ALL, (LPWSTR)&all, 0); + totalLen += allLen + strlenW(filter_all) + 2; + filter = HeapAlloc(GetProcessHeap(), 0, totalLen * sizeof(WCHAR)); + if (filter) + { + LPWSTR ptr; + + ptr = filter; + memcpy(ptr, baseFilter, baseLen * sizeof(WCHAR)); + ptr += baseLen; + *ptr++ = 0; + strcpyW(ptr, filterStr); + ptr += strlenW(filterStr) + 1; + memcpy(ptr, all, allLen * sizeof(WCHAR)); + ptr += allLen; + *ptr++ = 0; + strcpyW(ptr, filter_all); + ptr += strlenW(filter_all) + 1; + *ptr++ = 0; + } + return filter; +} + +static LRESULT CALLBACK export_file_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, + LPARAM lp) +{ + LRESULT ret = 0; + struct ExportWizData *data; + + switch (msg) + { + case WM_INITDIALOG: + { + PROPSHEETPAGEW *page = (PROPSHEETPAGEW *)lp; + + data = (struct ExportWizData *)page->lParam; + SetWindowLongPtrW(hwnd, DWLP_USER, (LPARAM)data); + if (data->pExportInfo->pwszExportFileName) + SendMessageW(GetDlgItem(hwnd, IDC_EXPORT_FILENAME), WM_SETTEXT, 0, + (LPARAM)data->pExportInfo->pwszExportFileName); + break; + } + case WM_NOTIFY: + { + NMHDR *hdr = (NMHDR *)lp; + + switch (hdr->code) + { + case PSN_WIZNEXT: + { + HWND fileNameEdit = GetDlgItem(hwnd, IDC_EXPORT_FILENAME); + DWORD len = SendMessageW(fileNameEdit, WM_GETTEXTLENGTH, 0, 0); + + data = (struct ExportWizData *)GetWindowLongPtrW(hwnd, DWLP_USER); + if (!len) + { + WCHAR title[MAX_STRING_LEN], error[MAX_STRING_LEN]; + LPCWSTR pTitle; + + if (data->pwszWizardTitle) + pTitle = data->pwszWizardTitle; + else + { + LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, + sizeof(title) / sizeof(title[0])); + pTitle = title; + } + LoadStringW(hInstance, IDS_IMPORT_EMPTY_FILE, error, + sizeof(error) / sizeof(error[0])); + MessageBoxW(hwnd, error, pTitle, MB_ICONERROR | MB_OK); + SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, 1); + ret = 1; + } + else + { + LPWSTR fileName = HeapAlloc(GetProcessHeap(), 0, + (len + 1) * sizeof(WCHAR)); + + if (fileName) + { + SendMessageW(fileNameEdit, WM_GETTEXT, len + 1, + (LPARAM)fileName); + fileName = export_append_extension(data, fileName); + if (!export_validate_filename(hwnd, data, fileName)) + { + HeapFree(GetProcessHeap(), 0, fileName); + SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, 1); + ret = 1; + } + else + data->fileName = fileName; + } + } + break; + } + case PSN_SETACTIVE: + PostMessageW(GetParent(hwnd), PSM_SETWIZBUTTONS, 0, + PSWIZB_BACK | PSWIZB_NEXT); + ret = TRUE; + break; + } + break; + } + case WM_COMMAND: + switch (wp) + { + case IDC_EXPORT_BROWSE_FILE: + { + OPENFILENAMEW ofn; + WCHAR fileBuf[MAX_PATH]; + + data = (struct ExportWizData *)GetWindowLongPtrW(hwnd, DWLP_USER); + memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = make_export_file_filter( + data->contextInfo.dwExportFormat, + data->pExportInfo->dwSubjectChoice); + ofn.lpstrFile = fileBuf; + ofn.nMaxFile = sizeof(fileBuf) / sizeof(fileBuf[0]); + fileBuf[0] = 0; + if (GetSaveFileNameW(&ofn)) + SendMessageW(GetDlgItem(hwnd, IDC_EXPORT_FILENAME), WM_SETTEXT, + 0, (LPARAM)ofn.lpstrFile); + HeapFree(GetProcessHeap(), 0, (LPWSTR)ofn.lpstrFilter); + break; + } + } + break; + } + return ret; +} + +static void show_export_details(HWND lv, struct ExportWizData *data) +{ + WCHAR text[MAX_STRING_LEN]; + LVITEMW item; + int contentID; + + item.mask = LVIF_TEXT; + if (data->fileName) + { + item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); + item.iSubItem = 0; + LoadStringW(hInstance, IDS_IMPORT_FILE, text, + sizeof(text)/ sizeof(text[0])); + item.pszText = text; + SendMessageW(lv, LVM_INSERTITEMW, 0, (LPARAM)&item); + item.iSubItem = 1; + item.pszText = data->fileName; + SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); + } + + item.pszText = text; + switch (data->pExportInfo->dwSubjectChoice) + { + case CRYPTUI_WIZ_EXPORT_CRL_CONTEXT: + case CRYPTUI_WIZ_EXPORT_CTL_CONTEXT: + case CRYPTUI_WIZ_EXPORT_CERT_STORE: + case CRYPTUI_WIZ_EXPORT_CERT_STORE_CERTIFICATES_ONLY: + /* do nothing */ + break; + default: + { + item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); + item.iSubItem = 0; + LoadStringW(hInstance, IDS_EXPORT_INCLUDE_CHAIN, text, + sizeof(text) / sizeof(text[0])); + SendMessageW(lv, LVM_INSERTITEMW, item.iItem, (LPARAM)&item); + item.iSubItem = 1; + LoadStringW(hInstance, + data->contextInfo.fExportChain ? IDS_YES : IDS_NO, text, + sizeof(text) / sizeof(text[0])); + SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); + + item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); + item.iSubItem = 0; + LoadStringW(hInstance, IDS_EXPORT_KEYS, text, + sizeof(text) / sizeof(text[0])); + SendMessageW(lv, LVM_INSERTITEMW, item.iItem, (LPARAM)&item); + item.iSubItem = 1; + LoadStringW(hInstance, + data->contextInfo.fExportPrivateKeys ? IDS_YES : IDS_NO, text, + sizeof(text) / sizeof(text[0])); + SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); + } + } + + item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); + item.iSubItem = 0; + LoadStringW(hInstance, IDS_EXPORT_FORMAT, text, + sizeof(text)/ sizeof(text[0])); + SendMessageW(lv, LVM_INSERTITEMW, 0, (LPARAM)&item); + + item.iSubItem = 1; + switch (data->pExportInfo->dwSubjectChoice) + { + case CRYPTUI_WIZ_EXPORT_CRL_CONTEXT: + contentID = IDS_EXPORT_FILTER_CRL; + break; + case CRYPTUI_WIZ_EXPORT_CTL_CONTEXT: + contentID = IDS_EXPORT_FILTER_CTL; + break; + case CRYPTUI_WIZ_EXPORT_CERT_STORE: + contentID = IDS_EXPORT_FILTER_SERIALIZED_CERT_STORE; + break; + default: + switch (data->contextInfo.dwExportFormat) + { + case CRYPTUI_WIZ_EXPORT_FORMAT_BASE64: + contentID = IDS_EXPORT_FILTER_BASE64_CERT; + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7: + contentID = IDS_EXPORT_FILTER_CMS; + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_PFX: + contentID = IDS_EXPORT_FILTER_PFX; + break; + default: + contentID = IDS_EXPORT_FILTER_CERT; + } + } + LoadStringW(hInstance, contentID, text, sizeof(text) / sizeof(text[0])); + SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); +} + +static inline BOOL save_der(HANDLE file, const BYTE *pb, DWORD cb) +{ + DWORD bytesWritten; + + return WriteFile(file, pb, cb, &bytesWritten, NULL); +} + +static BOOL save_base64(HANDLE file, const BYTE *pb, DWORD cb) +{ + BOOL ret; + DWORD size = 0; + + if ((ret = CryptBinaryToStringA(pb, cb, CRYPT_STRING_BASE64, NULL, &size))) + { + LPSTR buf = HeapAlloc(GetProcessHeap(), 0, size); + + if (buf) + { + if ((ret = CryptBinaryToStringA(pb, cb, CRYPT_STRING_BASE64, buf, + &size))) + ret = WriteFile(file, buf, size, &size, NULL); + HeapFree(GetProcessHeap(), 0, buf); + } + else + { + SetLastError(ERROR_OUTOFMEMORY); + ret = FALSE; + } + } + return ret; +} + +static inline BOOL save_store_as_cms(HANDLE file, HCERTSTORE store) +{ + return CertSaveStore(store, PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, + CERT_STORE_SAVE_AS_PKCS7, CERT_STORE_SAVE_TO_FILE, file, 0); +} + +static BOOL save_cert_as_cms(HANDLE file, PCCRYPTUI_WIZ_EXPORT_INFO pExportInfo, + BOOL includeChain) +{ + BOOL ret; + HCERTSTORE store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, + CERT_STORE_CREATE_NEW_FLAG, NULL); + + if (store) + { + if (includeChain) + { + HCERTSTORE addlStore = CertOpenStore(CERT_STORE_PROV_COLLECTION, + 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); + + if (addlStore) + { + DWORD i; + + ret = TRUE; + for (i = 0; ret && i < pExportInfo->cStores; i++) + ret = CertAddStoreToCollection(addlStore, + pExportInfo->rghStores, 0, 0); + if (ret) + { + PCCERT_CHAIN_CONTEXT chain; + + ret = CertGetCertificateChain(NULL, + pExportInfo->u.pCertContext, NULL, addlStore, NULL, 0, + NULL, &chain); + if (ret) + { + DWORD j; + + for (i = 0; ret && i < chain->cChain; i++) + for (j = 0; ret && j < chain->rgpChain[i]->cElement; + j++) + ret = CertAddCertificateContextToStore(store, + chain->rgpChain[i]->rgpElement[j]->pCertContext, + CERT_STORE_ADD_ALWAYS, NULL); + CertFreeCertificateChain(chain); + } + else + { + /* No chain could be created, just add the individual + * cert to the message. + */ + ret = CertAddCertificateContextToStore(store, + pExportInfo->u.pCertContext, CERT_STORE_ADD_ALWAYS, + NULL); + } + } + CertCloseStore(addlStore, 0); + } + else + ret = FALSE; + } + else + ret = CertAddCertificateContextToStore(store, + pExportInfo->u.pCertContext, CERT_STORE_ADD_ALWAYS, NULL); + if (ret) + ret = save_store_as_cms(file, store); + CertCloseStore(store, 0); + } + else + ret = FALSE; + return ret; +} + +static BOOL save_serialized_store(HANDLE file, HCERTSTORE store) +{ + return CertSaveStore(store, PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, + CERT_STORE_SAVE_AS_STORE, CERT_STORE_SAVE_TO_FILE, file, 0); +} + +static BOOL do_export(HANDLE file, PCCRYPTUI_WIZ_EXPORT_INFO pExportInfo, + PCCRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO pContextInfo) +{ + BOOL ret; + + if (pContextInfo->dwSize != sizeof(CRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO)) + { + SetLastError(E_INVALIDARG); + return FALSE; + } + switch (pExportInfo->dwSubjectChoice) + { + case CRYPTUI_WIZ_EXPORT_CRL_CONTEXT: + ret = save_der(file, + pExportInfo->u.pCRLContext->pbCrlEncoded, + pExportInfo->u.pCRLContext->cbCrlEncoded); + break; + case CRYPTUI_WIZ_EXPORT_CTL_CONTEXT: + ret = save_der(file, + pExportInfo->u.pCTLContext->pbCtlEncoded, + pExportInfo->u.pCTLContext->cbCtlEncoded); + break; + case CRYPTUI_WIZ_EXPORT_CERT_STORE: + ret = save_serialized_store(file, pExportInfo->u.hCertStore); + break; + case CRYPTUI_WIZ_EXPORT_CERT_STORE_CERTIFICATES_ONLY: + ret = save_store_as_cms(file, pExportInfo->u.hCertStore); + break; + default: + switch (pContextInfo->dwExportFormat) + { + case CRYPTUI_WIZ_EXPORT_FORMAT_DER: + ret = save_der(file, pExportInfo->u.pCertContext->pbCertEncoded, + pExportInfo->u.pCertContext->cbCertEncoded); + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_BASE64: + ret = save_base64(file, + pExportInfo->u.pCertContext->pbCertEncoded, + pExportInfo->u.pCertContext->cbCertEncoded); + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7: + ret = save_cert_as_cms(file, pExportInfo, + pContextInfo->fExportChain); + break; + case CRYPTUI_WIZ_EXPORT_FORMAT_PFX: + FIXME("unimplemented for PFX\n"); + ret = FALSE; + break; + default: + SetLastError(E_FAIL); + ret = FALSE; + } + } + return ret; +} + +static LRESULT CALLBACK export_finish_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, + LPARAM lp) +{ + LRESULT ret = 0; + struct ExportWizData *data; + + switch (msg) + { + case WM_INITDIALOG: + { + PROPSHEETPAGEW *page = (PROPSHEETPAGEW *)lp; + HWND lv = GetDlgItem(hwnd, IDC_EXPORT_SETTINGS); + RECT rc; + LVCOLUMNW column; + + data = (struct ExportWizData *)page->lParam; + SetWindowLongPtrW(hwnd, DWLP_USER, (LPARAM)data); + SendMessageW(GetDlgItem(hwnd, IDC_EXPORT_TITLE), WM_SETFONT, + (WPARAM)data->titleFont, TRUE); + GetWindowRect(lv, &rc); + column.mask = LVCF_WIDTH; + column.cx = (rc.right - rc.left) / 2 - 2; + SendMessageW(lv, LVM_INSERTCOLUMNW, 0, (LPARAM)&column); + SendMessageW(lv, LVM_INSERTCOLUMNW, 1, (LPARAM)&column); + show_export_details(lv, data); + break; + } + case WM_NOTIFY: + { + NMHDR *hdr = (NMHDR *)lp; + + switch (hdr->code) + { + case PSN_SETACTIVE: + { + HWND lv = GetDlgItem(hwnd, IDC_EXPORT_SETTINGS); + + data = (struct ExportWizData *)GetWindowLongPtrW(hwnd, DWLP_USER); + SendMessageW(lv, LVM_DELETEALLITEMS, 0, 0); + show_export_details(lv, data); + PostMessageW(GetParent(hwnd), PSM_SETWIZBUTTONS, 0, + PSWIZB_BACK | PSWIZB_FINISH); + ret = TRUE; + break; + } + case PSN_WIZFINISH: + { + int messageID; + WCHAR title[MAX_STRING_LEN], message[MAX_STRING_LEN]; + LPCWSTR pTitle; + DWORD mbFlags; + + data = (struct ExportWizData *)GetWindowLongPtrW(hwnd, DWLP_USER); + if ((data->success = do_export(data->file, data->pExportInfo, + &data->contextInfo))) + { + messageID = IDS_EXPORT_SUCCEEDED; + mbFlags = MB_OK; + } + else + { + messageID = IDS_EXPORT_FAILED; + mbFlags = MB_OK | MB_ICONERROR; + } + if (data->pwszWizardTitle) + pTitle = data->pwszWizardTitle; + else + { + LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, + sizeof(title) / sizeof(title[0])); + pTitle = title; + } + LoadStringW(hInstance, messageID, message, + sizeof(message) / sizeof(message[0])); + MessageBoxW(hwnd, message, pTitle, mbFlags); + break; + } + } + break; + } + } + return ret; +} + +static BOOL show_export_ui(DWORD dwFlags, HWND hwndParent, + LPCWSTR pwszWizardTitle, PCCRYPTUI_WIZ_EXPORT_INFO pExportInfo, void *pvoid) +{ + PROPSHEETHEADERW hdr; + PROPSHEETPAGEW pages[4]; + struct ExportWizData data; + int nPages = 0; + BOOL showFormatPage = TRUE; + + data.dwFlags = dwFlags; + data.pwszWizardTitle = pwszWizardTitle; + data.pExportInfo = pExportInfo; + data.contextInfo.dwSize = sizeof(data.contextInfo); + data.contextInfo.dwExportFormat = CRYPTUI_WIZ_EXPORT_FORMAT_DER; + data.contextInfo.fExportChain = FALSE; + data.contextInfo.fStrongEncryption = FALSE; + data.contextInfo.fExportPrivateKeys = FALSE; + if (pExportInfo->dwSubjectChoice == CRYPTUI_WIZ_EXPORT_CERT_CONTEXT && + pvoid) + memcpy(&data.contextInfo, pvoid, + min(((PCCRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO)pvoid)->dwSize, + sizeof(data.contextInfo))); + data.fileName = NULL; + data.file = INVALID_HANDLE_VALUE; + data.success = FALSE; + + memset(&pages, 0, sizeof(pages)); + + pages[nPages].dwSize = sizeof(pages[0]); + pages[nPages].hInstance = hInstance; + pages[nPages].u.pszTemplate = MAKEINTRESOURCEW(IDD_EXPORT_WELCOME); + pages[nPages].pfnDlgProc = export_welcome_dlg_proc; + pages[nPages].dwFlags = PSP_HIDEHEADER; + pages[nPages].lParam = (LPARAM)&data; + nPages++; + + switch (pExportInfo->dwSubjectChoice) + { + case CRYPTUI_WIZ_EXPORT_CRL_CONTEXT: + case CRYPTUI_WIZ_EXPORT_CTL_CONTEXT: + showFormatPage = FALSE; + data.contextInfo.dwExportFormat = CRYPTUI_WIZ_EXPORT_FORMAT_DER; + break; + case CRYPTUI_WIZ_EXPORT_CERT_STORE: + showFormatPage = FALSE; + data.contextInfo.dwExportFormat = + CRYPTUI_WIZ_EXPORT_FORMAT_SERIALIZED_CERT_STORE; + break; + case CRYPTUI_WIZ_EXPORT_CERT_STORE_CERTIFICATES_ONLY: + showFormatPage = FALSE; + data.contextInfo.dwExportFormat = CRYPTUI_WIZ_EXPORT_FORMAT_PKCS7; + break; + } + if (showFormatPage) + { + pages[nPages].dwSize = sizeof(pages[0]); + pages[nPages].hInstance = hInstance; + pages[nPages].u.pszTemplate = MAKEINTRESOURCEW(IDD_EXPORT_FORMAT); + pages[nPages].pfnDlgProc = export_format_dlg_proc; + pages[nPages].dwFlags = PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; + pages[nPages].pszHeaderTitle = + MAKEINTRESOURCEW(IDS_EXPORT_FORMAT_TITLE); + pages[nPages].pszHeaderSubTitle = + MAKEINTRESOURCEW(IDS_EXPORT_FORMAT_SUBTITLE); + pages[nPages].lParam = (LPARAM)&data; + nPages++; + } + + pages[nPages].dwSize = sizeof(pages[0]); + pages[nPages].hInstance = hInstance; + pages[nPages].u.pszTemplate = MAKEINTRESOURCEW(IDD_EXPORT_FILE); + pages[nPages].pfnDlgProc = export_file_dlg_proc; + pages[nPages].dwFlags = PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; + pages[nPages].pszHeaderTitle = MAKEINTRESOURCEW(IDS_EXPORT_FILE_TITLE); + pages[nPages].pszHeaderSubTitle = + MAKEINTRESOURCEW(IDS_EXPORT_FILE_SUBTITLE); + pages[nPages].lParam = (LPARAM)&data; + nPages++; + + pages[nPages].dwSize = sizeof(pages[0]); + pages[nPages].hInstance = hInstance; + pages[nPages].u.pszTemplate = MAKEINTRESOURCEW(IDD_EXPORT_FINISH); + pages[nPages].pfnDlgProc = export_finish_dlg_proc; + pages[nPages].dwFlags = PSP_HIDEHEADER; + pages[nPages].lParam = (LPARAM)&data; + nPages++; + + memset(&hdr, 0, sizeof(hdr)); + hdr.dwSize = sizeof(hdr); + hdr.hwndParent = hwndParent; + hdr.dwFlags = PSH_PROPSHEETPAGE | PSH_WIZARD97_NEW | PSH_HEADER | + PSH_WATERMARK; + hdr.hInstance = hInstance; + if (pwszWizardTitle) + hdr.pszCaption = pwszWizardTitle; + else + hdr.pszCaption = MAKEINTRESOURCEW(IDS_EXPORT_WIZARD); + hdr.u3.ppsp = pages; + hdr.nPages = nPages; + hdr.u4.pszbmWatermark = MAKEINTRESOURCEW(IDB_CERT_WATERMARK); + hdr.u5.pszbmHeader = MAKEINTRESOURCEW(IDB_CERT_HEADER); + PropertySheetW(&hdr); + DeleteObject(data.titleFont); + CloseHandle(data.file); + HeapFree(GetProcessHeap(), 0, data.fileName); + return data.success; +} + +BOOL WINAPI CryptUIWizExport(DWORD dwFlags, HWND hwndParent, + LPCWSTR pwszWizardTitle, PCCRYPTUI_WIZ_EXPORT_INFO pExportInfo, void *pvoid) +{ + BOOL ret; + + TRACE("(%08x, %p, %s, %p, %p)\n", dwFlags, hwndParent, + debugstr_w(pwszWizardTitle), pExportInfo, pvoid); + + if (!(dwFlags & CRYPTUI_WIZ_NO_UI)) + ret = show_export_ui(dwFlags, hwndParent, pwszWizardTitle, pExportInfo, + pvoid); + else + { + HANDLE file = CreateFileW(pExportInfo->pwszExportFileName, + GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + CREATE_ALWAYS, 0, NULL); + + if (file != INVALID_HANDLE_VALUE) + { + ret = do_export(file, pExportInfo, pvoid); + CloseHandle(file); + } + else + ret = FALSE; + } + return ret; +} Modified: trunk/reactos/include/psdk/cryptuiapi.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/cryptuiapi.h?…
============================================================================== --- trunk/reactos/include/psdk/cryptuiapi.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/cryptuiapi.h [iso-8859-1] Sat Jan 31 05:47:29 2009 @@ -271,6 +271,7 @@ PCCERT_CONTEXT pCertContext; PCCTL_CONTEXT pCTLContext; PCCRL_CONTEXT pCRLContext; + HCERTSTORE hCertStore; } DUMMYUNIONNAME; DWORD cStores; HCERTSTORE *rghStores;
15 years, 10 months
1
0
0
0
[cwittich] 39222: sync msxml3_winetest to wine 1.1.14
by cwittich@svn.reactos.org
Author: cwittich Date: Sat Jan 31 05:27:33 2009 New Revision: 39222 URL:
http://svn.reactos.org/svn/reactos?rev=39222&view=rev
Log: sync msxml3_winetest to wine 1.1.14 Modified: trunk/rostests/winetests/msxml3/domdoc.c trunk/rostests/winetests/msxml3/saxreader.c Modified: trunk/rostests/winetests/msxml3/domdoc.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/msxml3/domdoc.c…
============================================================================== --- trunk/rostests/winetests/msxml3/domdoc.c [iso-8859-1] (original) +++ trunk/rostests/winetests/msxml3/domdoc.c [iso-8859-1] Sat Jan 31 05:27:33 2009 @@ -455,6 +455,10 @@ ok( b == VARIANT_FALSE, "failed to load XML string\n"); SysFreeString( str ); + r = IXMLDOMDocument_get_async( doc, &b ); + ok( r == S_OK, "get_async failed (%08x)\n", r); + ok( b == VARIANT_TRUE, "Wrong default value\n"); + /* check that there's no document element */ element = NULL; r = IXMLDOMDocument_get_documentElement( doc, &element ); Modified: trunk/rostests/winetests/msxml3/saxreader.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/msxml3/saxreade…
============================================================================== --- trunk/rostests/winetests/msxml3/saxreader.c [iso-8859-1] (original) +++ trunk/rostests/winetests/msxml3/saxreader.c [iso-8859-1] Sat Jan 31 05:27:33 2009 @@ -546,7 +546,7 @@ CreateStreamOnHGlobal(NULL, TRUE, &iStream); liSize.QuadPart = strlen(szTestXML); IStream_SetSize(iStream, liSize); - IStream_Write(iStream, (void const*)szTestXML, strlen(szTestXML), &bytesWritten); + IStream_Write(iStream, szTestXML, strlen(szTestXML), &bytesWritten); liPos.QuadPart = 0; IStream_Seek(iStream, liPos, STREAM_SEEK_SET, NULL); V_VT(&var) = VT_UNKNOWN|VT_DISPATCH;
15 years, 10 months
1
0
0
0
[cwittich] 39221: sync msxml3 to wine 1.1.14
by cwittich@svn.reactos.org
Author: cwittich Date: Sat Jan 31 05:27:22 2009 New Revision: 39221 URL:
http://svn.reactos.org/svn/reactos?rev=39221&view=rev
Log: sync msxml3 to wine 1.1.14 Modified: trunk/reactos/dll/win32/msxml3/cdata.c trunk/reactos/dll/win32/msxml3/comment.c trunk/reactos/dll/win32/msxml3/domdoc.c trunk/reactos/dll/win32/msxml3/element.c trunk/reactos/dll/win32/msxml3/node.c trunk/reactos/dll/win32/msxml3/regsvr.c trunk/reactos/dll/win32/msxml3/saxreader.c trunk/reactos/dll/win32/msxml3/text.c trunk/reactos/dll/win32/msxml3/xmldoc.c trunk/reactos/dll/win32/msxml3/xmlelem.c Modified: trunk/reactos/dll/win32/msxml3/cdata.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/cdata.c?r…
============================================================================== --- trunk/reactos/dll/win32/msxml3/cdata.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/cdata.c [iso-8859-1] Sat Jan 31 05:27:22 2009 @@ -520,7 +520,7 @@ long *len) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlnode *pDOMNode = impl_from_IXMLDOMNode( (IXMLDOMNode*)This->node ); + xmlnode *pDOMNode = impl_from_IXMLDOMNode( This->node ); xmlChar *pContent; long nLength = 0; @@ -546,7 +546,7 @@ long offset, long count, BSTR *p) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlnode *pDOMNode = impl_from_IXMLDOMNode( (IXMLDOMNode*)This->node ); + xmlnode *pDOMNode = impl_from_IXMLDOMNode( This->node ); xmlChar *pContent; long nLength = 0; HRESULT hr = S_FALSE; @@ -591,7 +591,7 @@ BSTR p) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlnode *pDOMNode = impl_from_IXMLDOMNode( (IXMLDOMNode*)This->node ); + xmlnode *pDOMNode = impl_from_IXMLDOMNode( This->node ); xmlChar *pContent; HRESULT hr = S_FALSE; @@ -601,7 +601,7 @@ if(p == NULL || SysStringLen(p) == 0) return S_OK; - pContent = xmlChar_from_wchar( (WCHAR*)p ); + pContent = xmlChar_from_wchar( p ); if(pContent) { if(xmlTextConcat(pDOMNode->node, pContent, SysStringLen(p) ) == 0) @@ -621,7 +621,7 @@ long offset, BSTR p) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - xmlnode *pDOMNode = impl_from_IXMLDOMNode( (IXMLDOMNode*)This->node ); + xmlnode *pDOMNode = impl_from_IXMLDOMNode( This->node ); xmlChar *pXmlContent; BSTR sNewString; HRESULT hr = S_FALSE; @@ -667,7 +667,7 @@ sNewString[nLengthP + nLength] = 0; - str = xmlChar_from_wchar((WCHAR*)sNewString); + str = xmlChar_from_wchar(sNewString); if(str) { xmlNodeSetContent(pDOMNode->node, str); Modified: trunk/reactos/dll/win32/msxml3/comment.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/comment.c…
============================================================================== --- trunk/reactos/dll/win32/msxml3/comment.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/comment.c [iso-8859-1] Sat Jan 31 05:27:22 2009 @@ -595,7 +595,7 @@ if(p == NULL || SysStringLen(p) == 0) return S_OK; - pContent = xmlChar_from_wchar( (WCHAR*)p ); + pContent = xmlChar_from_wchar( p ); if(pContent) { /* Older versions of libxml < 2.6.27 didn't correctly support @@ -675,7 +675,7 @@ sNewString[nLengthP + nLength] = 0; - str = xmlChar_from_wchar((WCHAR*)sNewString); + str = xmlChar_from_wchar(sNewString); if(str) { xmlNodeSetContent(pDOMNode->node, str); Modified: trunk/reactos/dll/win32/msxml3/domdoc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/domdoc.c?…
============================================================================== --- trunk/reactos/dll/win32/msxml3/domdoc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/domdoc.c [iso-8859-1] Sat Jan 31 05:27:22 2009 @@ -357,8 +357,26 @@ static HRESULT WINAPI xmldoc_IPersistStream_Save( IPersistStream *iface, LPSTREAM pStm, BOOL fClearDirty) { - FIXME("(%p, %p, %d): stub!\n", iface, pStm, fClearDirty); - return E_NOTIMPL; + domdoc *This = impl_from_IPersistStream(iface); + HRESULT hr; + BSTR xmlString; + + TRACE("(%p, %p, %d)\n", iface, pStm, fClearDirty); + + hr = IXMLDOMNode_get_xml( This->node, &xmlString ); + if(hr == S_OK) + { + DWORD count; + DWORD len = strlenW(xmlString) * sizeof(WCHAR); + + hr = IStream_Write( pStm, xmlString, len, &count ); + + SysFreeString(xmlString); + } + + TRACE("ret 0x%08x\n", hr); + + return hr; } static HRESULT WINAPI xmldoc_IPersistStream_GetSizeMax( @@ -441,11 +459,11 @@ } else if (IsEqualGUID(&IID_IPersistStream, riid)) { - *ppvObject = (IPersistStream*)&(This->lpvtblIPersistStream); + *ppvObject = &(This->lpvtblIPersistStream); } else if (IsEqualGUID(&IID_IObjectWithSite, riid)) { - *ppvObject = (IObjectWithSite*)&(This->lpvtblIObjectWithSite); + *ppvObject = &(This->lpvtblIObjectWithSite); } else if( IsEqualGUID( riid, &IID_ISupportErrorInfo )) { @@ -1023,7 +1041,7 @@ TRACE("%p->(%s,%p)\n", iface, debugstr_w(tagname), element); - xml_name = xmlChar_from_wchar((WCHAR*)tagname); + xml_name = xmlChar_from_wchar(tagname); xmlnode = xmlNewDocNode(get_doc(This), NULL, xml_name, NULL); xmldoc_add_orphan(xmlnode->doc, xmlnode); @@ -1080,7 +1098,7 @@ *text = NULL; - xml_content = xmlChar_from_wchar((WCHAR*)data); + xml_content = xmlChar_from_wchar(data); xmlnode = xmlNewText(xml_content); HeapFree(GetProcessHeap(), 0, xml_content); @@ -1112,7 +1130,7 @@ *comment = NULL; - xml_content = xmlChar_from_wchar((WCHAR*)data); + xml_content = xmlChar_from_wchar(data); xmlnode = xmlNewComment(xml_content); HeapFree(GetProcessHeap(), 0, xml_content); @@ -1144,7 +1162,7 @@ *cdata = NULL; - xml_content = xmlChar_from_wchar((WCHAR*)data); + xml_content = xmlChar_from_wchar(data); xmlnode = xmlNewCDataBlock(get_doc( This ), xml_content, strlen( (char*)xml_content) ); HeapFree(GetProcessHeap(), 0, xml_content); @@ -1179,8 +1197,8 @@ if(!target || lstrlenW(target) == 0) return E_FAIL; - xml_target = xmlChar_from_wchar((WCHAR*)target); - xml_content = xmlChar_from_wchar((WCHAR*)data); + xml_target = xmlChar_from_wchar(target); + xml_content = xmlChar_from_wchar(data); xmlnode = xmlNewDocPI(get_doc(This), xml_target, xml_content); xmldoc_add_orphan(xmlnode->doc, xmlnode); @@ -1214,7 +1232,7 @@ *attribute = NULL; - xml_name = xmlChar_from_wchar((WCHAR*)name); + xml_name = xmlChar_from_wchar(name); xmlnode = (xmlNode *)xmlNewProp(NULL, xml_name, NULL); HeapFree(GetProcessHeap(), 0, xml_name); @@ -1246,7 +1264,7 @@ *entityRef = NULL; - xml_name = xmlChar_from_wchar((WCHAR*)name); + xml_name = xmlChar_from_wchar(name); xmlnode = xmlNewReference(get_doc( This ), xml_name ); HeapFree(GetProcessHeap(), 0, xml_name); @@ -1312,13 +1330,16 @@ TRACE("(%p)->(type,%s,%s,%p)\n", This, debugstr_w(name), debugstr_w(namespaceURI), node); + if(namespaceURI && namespaceURI[0]) + FIXME("nodes with namespaces currently not supported.\n"); + hr = get_node_type(Type, &node_type); if(FAILED(hr)) return hr; TRACE("node_type %d\n", node_type); - xml_name = xmlChar_from_wchar((WCHAR*)name); + xml_name = xmlChar_from_wchar(name); switch(node_type) { @@ -2189,7 +2210,7 @@ doc->lpvtblIObjectSafety = &domdocObjectSafetyVtbl; doc->lpvtblISupportErrorInfo = &support_error_vtbl; doc->ref = 1; - doc->async = 0; + doc->async = VARIANT_TRUE; doc->validating = 0; doc->resolving = 0; doc->preserving = 0; @@ -2258,7 +2279,7 @@ if (FAILED(hr)) return NULL; - return (IUnknown*)pObj; + return pObj; } #else Modified: trunk/reactos/dll/win32/msxml3/element.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/element.c…
============================================================================== --- trunk/reactos/dll/win32/msxml3/element.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/element.c [iso-8859-1] Sat Jan 31 05:27:22 2009 @@ -644,6 +644,7 @@ { domelem *This = impl_from_IXMLDOMElement( iface ); LPWSTR szPattern; + xmlNodePtr element; HRESULT hr; TRACE("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), resultList); @@ -654,7 +655,11 @@ lstrcpyW(szPattern+3, bstrName); TRACE("%s\n", debugstr_w(szPattern)); - hr = queryresult_create(get_element(This), szPattern, resultList); + element = get_element(This); + if (!element) + hr = E_FAIL; + else + hr = queryresult_create(element, szPattern, resultList); HeapFree(GetProcessHeap(), 0, szPattern); return hr; Modified: trunk/reactos/dll/win32/msxml3/node.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/node.c?re…
============================================================================== --- trunk/reactos/dll/win32/msxml3/node.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/node.c [iso-8859-1] Sat Jan 31 05:27:22 2009 @@ -345,7 +345,7 @@ case XML_PI_NODE: case XML_TEXT_NODE: { - str = xmlChar_from_wchar((WCHAR*)V_BSTR(&string_value)); + str = xmlChar_from_wchar(V_BSTR(&string_value)); xmlNodeSetContent(This->node, str); HeapFree(GetProcessHeap(),0,str); hr = S_OK; @@ -904,7 +904,7 @@ break; } - str = xmlChar_from_wchar((WCHAR*)text); + str = xmlChar_from_wchar(text); /* Escape the string. */ str2 = xmlEncodeEntitiesReentrant(This->node->doc, str); @@ -1060,7 +1060,7 @@ { xmlNsPtr pNS = NULL; xmlAttrPtr pAttr = NULL; - xmlChar* str = xmlChar_from_wchar((WCHAR*)dataTypeName); + xmlChar* str = xmlChar_from_wchar(dataTypeName); pAttr = xmlHasNsProp(This->node, (xmlChar*)"dt", (xmlChar*)"urn:schemas-microsoft-com:datatypes"); Modified: trunk/reactos/dll/win32/msxml3/regsvr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/regsvr.c?…
============================================================================== --- trunk/reactos/dll/win32/msxml3/regsvr.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/regsvr.c [iso-8859-1] Sat Jan 31 05:27:22 2009 @@ -564,6 +564,14 @@ "Msxml2.SAXXMLReader", "3.0" }, + { &CLSID_SAXXMLReader30, + "SAX XML Reader 3.0", + NULL, + "msxml3.dll", + "Both", + "Msxml2.SAXXMLReader", + "3.0" + }, { NULL } /* list terminator */ }; @@ -651,6 +659,16 @@ { "Msxml2.XMLSchemaCache.3.0", "XML Schema Cache 3.0", &CLSID_XMLSchemaCache30, + NULL + }, + { "Msxml2.SAXXMLReader", + "SAX XML Reader", + &CLSID_SAXXMLReader, + "Msxml2.SAXXMLReader.3.0" + }, + { "Msxml2.SAXXMLReader.3.0", + "SAX XML Reader 3.0", + &CLSID_SAXXMLReader30, NULL }, Modified: trunk/reactos/dll/win32/msxml3/saxreader.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/saxreader…
============================================================================== --- trunk/reactos/dll/win32/msxml3/saxreader.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/saxreader.c [iso-8859-1] Sat Jan 31 05:27:22 2009 @@ -457,9 +457,8 @@ { saxattributes *This = impl_from_IVBSAXAttributes( iface ); return ISAXAttributes_getIndexFromName( - (ISAXAttributes*)&This->lpSAXAttributesVtbl, - (const WCHAR*)uri, SysStringLen(uri), - (const WCHAR*)localName, SysStringLen(localName), index); + (ISAXAttributes*)&This->lpSAXAttributesVtbl, uri, SysStringLen(uri), + localName, SysStringLen(localName), index); } static HRESULT WINAPI ivbsaxattributes_getIndexFromQName( @@ -469,8 +468,8 @@ { saxattributes *This = impl_from_IVBSAXAttributes( iface ); return ISAXAttributes_getIndexFromQName( - (ISAXAttributes*)&This->lpSAXAttributesVtbl, - (const WCHAR*)QName, SysStringLen(QName), index); + (ISAXAttributes*)&This->lpSAXAttributesVtbl, QName, + SysStringLen(QName), index); } static HRESULT WINAPI ivbsaxattributes_getType( @@ -494,10 +493,8 @@ int len; saxattributes *This = impl_from_IVBSAXAttributes( iface ); return ISAXAttributes_getTypeFromName( - (ISAXAttributes*)&This->lpSAXAttributesVtbl, - (const WCHAR*)uri, SysStringLen(uri), - (const WCHAR*)localName, SysStringLen(localName), - (const WCHAR**)type, &len); + (ISAXAttributes*)&This->lpSAXAttributesVtbl, uri, SysStringLen(uri), + localName, SysStringLen(localName), (const WCHAR**)type, &len); } static HRESULT WINAPI ivbsaxattributes_getTypeFromQName( @@ -508,9 +505,8 @@ int len; saxattributes *This = impl_from_IVBSAXAttributes( iface ); return ISAXAttributes_getTypeFromQName( - (ISAXAttributes*)&This->lpSAXAttributesVtbl, - (const WCHAR*)QName, SysStringLen(QName), - (const WCHAR**)type, &len); + (ISAXAttributes*)&This->lpSAXAttributesVtbl, QName, + SysStringLen(QName), (const WCHAR**)type, &len); } static HRESULT WINAPI ivbsaxattributes_getValue( @@ -534,10 +530,8 @@ int len; saxattributes *This = impl_from_IVBSAXAttributes( iface ); return ISAXAttributes_getValueFromName( - (ISAXAttributes*)&This->lpSAXAttributesVtbl, - (const WCHAR*)uri, SysStringLen(uri), - (const WCHAR*)localName, SysStringLen(localName), - (const WCHAR**)value, &len); + (ISAXAttributes*)&This->lpSAXAttributesVtbl, uri, SysStringLen(uri), + localName, SysStringLen(localName), (const WCHAR**)value, &len); } static HRESULT WINAPI ivbsaxattributes_getValueFromQName( @@ -548,9 +542,8 @@ int len; saxattributes *This = impl_from_IVBSAXAttributes( iface ); return ISAXAttributes_getValueFromQName( - (ISAXAttributes*)&This->lpSAXAttributesVtbl, - (const WCHAR*)QName, SysStringLen(QName), - (const WCHAR**)value, &len); + (ISAXAttributes*)&This->lpSAXAttributesVtbl, QName, + SysStringLen(QName), (const WCHAR**)value, &len); } static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl = @@ -1329,7 +1322,7 @@ len = MultiByteToWideChar(CP_UNIXCP, 0, message, -1, NULL, 0); wszError = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len); if(wszError) - MultiByteToWideChar(CP_UNIXCP, 0, message, -1, (LPWSTR)wszError, len); + MultiByteToWideChar(CP_UNIXCP, 0, message, -1, wszError, len); if(This->vbInterface) { @@ -2031,7 +2024,7 @@ hr = SafeArrayGetUBound(V_ARRAY(&varInput), 1, &uBound); if(hr != S_OK) break; dataRead = (uBound-lBound)*SafeArrayGetElemsize(V_ARRAY(&varInput)); - hr = SafeArrayAccessData(V_ARRAY(&varInput), (void**)&pSAData); + hr = SafeArrayAccessData(V_ARRAY(&varInput), &pSAData); if(hr != S_OK) break; hr = internal_parseBuffer(This, pSAData, dataRead, vbInterface); SafeArrayUnaccessData(V_ARRAY(&varInput)); @@ -2267,7 +2260,7 @@ } else if( IsEqualGUID( riid, &IID_ISAXXMLReader )) { - *ppvObject = (ISAXXMLReader*)&This->lpSAXXMLReaderVtbl; + *ppvObject = &This->lpSAXXMLReaderVtbl; } else { Modified: trunk/reactos/dll/win32/msxml3/text.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/text.c?re…
============================================================================== --- trunk/reactos/dll/win32/msxml3/text.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/text.c [iso-8859-1] Sat Jan 31 05:27:22 2009 @@ -603,7 +603,7 @@ if(p == NULL || SysStringLen(p) == 0) return S_OK; - pContent = xmlChar_from_wchar( (WCHAR*)p ); + pContent = xmlChar_from_wchar( p ); if(pContent) { if(xmlTextConcat(pDOMNode->node, pContent, SysStringLen(p) ) == 0) @@ -669,7 +669,7 @@ sNewString[nLengthP + nLength] = 0; - str = xmlChar_from_wchar((WCHAR*)sNewString); + str = xmlChar_from_wchar(sNewString); if(str) { xmlNodeSetContent(pDOMNode->node, str); Modified: trunk/reactos/dll/win32/msxml3/xmldoc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/xmldoc.c?…
============================================================================== --- trunk/reactos/dll/win32/msxml3/xmldoc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/xmldoc.c [iso-8859-1] Sat Jan 31 05:27:22 2009 @@ -86,7 +86,7 @@ else if (IsEqualGUID(&IID_IPersistStreamInit, riid) || IsEqualGUID(&IID_IPersistStream, riid)) { - *ppvObject = (IPersistStreamInit *)&(This->lpvtblIPersistStreamInit); + *ppvObject = &(This->lpvtblIPersistStreamInit); } else { Modified: trunk/reactos/dll/win32/msxml3/xmlelem.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/xmlelem.c…
============================================================================== --- trunk/reactos/dll/win32/msxml3/xmlelem.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/xmlelem.c [iso-8859-1] Sat Jan 31 05:27:22 2009 @@ -516,7 +516,7 @@ } else if (IsEqualGUID(riid, &IID_IEnumVARIANT)) { - *ppvObject = (IEnumVARIANT *)&(This->lpvtblIEnumVARIANT); + *ppvObject = &(This->lpvtblIEnumVARIANT); } else {
15 years, 10 months
1
0
0
0
[dgorbachev] 39220: "whois" -> "nicname"
by dgorbachev@svn.reactos.org
Author: dgorbachev Date: Sat Jan 31 03:37:35 2009 New Revision: 39220 URL:
http://svn.reactos.org/svn/reactos?rev=39220&view=rev
Log: "whois" -> "nicname" Modified: trunk/reactos/base/applications/network/whois/whois.c Modified: trunk/reactos/base/applications/network/whois/whois.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
============================================================================== --- trunk/reactos/base/applications/network/whois/whois.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/whois/whois.c [iso-8859-1] Sat Jan 31 03:37:35 2009 @@ -130,9 +130,9 @@ } memcpy((char *)&sin.sin_addr, hp->h_addr, hp->h_length); - sp = getservbyname("whois", "tcp"); + sp = getservbyname("nicname", "tcp"); if (sp == NULL) { - (void)fprintf(stderr, "whois: whois/tcp: unknown service\n"); + (void)fprintf(stderr, "whois: nicname/tcp: unknown service\n"); cleanup(1); }
15 years, 10 months
1
0
0
0
[cwittich] 39219: tabs -> spaces
by cwittich@svn.reactos.org
Author: cwittich Date: Sat Jan 31 02:48:59 2009 New Revision: 39219 URL:
http://svn.reactos.org/svn/reactos?rev=39219&view=rev
Log: tabs -> spaces Modified: trunk/reactos/tools/xml.cpp Modified: trunk/reactos/tools/xml.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/xml.cpp?rev=39219&r1…
============================================================================== --- trunk/reactos/tools/xml.cpp [iso-8859-1] (original) +++ trunk/reactos/tools/xml.cpp [iso-8859-1] Sat Jan 31 02:48:59 2009 @@ -70,8 +70,8 @@ if (*str) { strvec[strlen(&strvec[0])] = *str; str++; } while (*str) { - strvec.push_back(*str); - str++; + strvec.push_back(*str); + str++; } strvec.push_back(0); } @@ -88,42 +88,42 @@ } XMLException::XMLException ( - const std::string& location, - const char* format, ... ) -{ - va_list args; - va_start ( args, format ); - SetExceptionV ( location, format, args ); - va_end ( args ); + const std::string& location, + const char* format, ... ) +{ + va_list args; + va_start ( args, format ); + SetExceptionV ( location, format, args ); + va_end ( args ); } void XMLException::SetExceptionV ( const std::string& location, const char* format, va_list args ) { - _e = location + ": " + ssvprintf(format,args); + _e = location + ": " + ssvprintf(format,args); } void XMLException::SetException ( const std::string& location, const char* format, ... ) { - va_list args; - va_start ( args, format ); - SetExceptionV ( location, format, args ); - va_end ( args ); + va_list args; + va_start ( args, format ); + SetExceptionV ( location, format, args ); + va_end ( args ); } XMLIncludes::~XMLIncludes() { - for ( size_t i = 0; i < this->size(); i++ ) - delete (*this)[i]; + for ( size_t i = 0; i < this->size(); i++ ) + delete (*this)[i]; } void InitWorkingDirectory() { - // store the current directory for path calculations - working_directory.resize ( MAX_PATH ); - working_directory[0] = 0; - getcwd ( &working_directory[0], working_directory.size() ); - working_directory.resize ( strlen ( working_directory.c_str() ) ); + // store the current directory for path calculations + working_directory.resize ( MAX_PATH ); + working_directory[0] = 0; + getcwd ( &working_directory[0], working_directory.size() ); + working_directory.resize ( strlen ( working_directory.c_str() ) ); } #ifdef _MSC_VER @@ -134,185 +134,185 @@ filelen ( FILE* f ) { #ifdef WIN32 - return _filelengthi64 ( _fileno(f) ); + return _filelengthi64 ( _fileno(f) ); #else # if defined(__FreeBSD__) || defined(__APPLE__) || defined(__CYGWIN__) - struct stat file_stat; - if ( fstat(fileno(f), &file_stat) != 0 ) + struct stat file_stat; + if ( fstat(fileno(f), &file_stat) != 0 ) # else - struct stat64 file_stat; - if ( fstat64(fileno(f), &file_stat) != 0 ) + struct stat64 file_stat; + if ( fstat64(fileno(f), &file_stat) != 0 ) # endif // __FreeBSD__ - return 0; - return file_stat.st_size; + return 0; + return file_stat.st_size; #endif // WIN32 } Path::Path() { - if ( !working_directory.size() ) - InitWorkingDirectory(); - string s ( working_directory ); - const char* p = strtok ( &s[0], "/\\" ); - while ( p ) - { - if ( *p ) - path.push_back ( p ); - p = strtok ( NULL, "/\\" ); - } + if ( !working_directory.size() ) + InitWorkingDirectory(); + string s ( working_directory ); + const char* p = strtok ( &s[0], "/\\" ); + while ( p ) + { + if ( *p ) + path.push_back ( p ); + p = strtok ( NULL, "/\\" ); + } } Path::Path ( const Path& cwd, const string& file ) { - string s ( cwd.Fixup ( file, false ) ); - const char* p = strtok ( &s[0], "/\\" ); - while ( p ) - { - if ( *p ) - path.push_back ( p ); - p = strtok ( NULL, "/\\" ); - } + string s ( cwd.Fixup ( file, false ) ); + const char* p = strtok ( &s[0], "/\\" ); + while ( p ) + { + if ( *p ) + path.push_back ( p ); + p = strtok ( NULL, "/\\" ); + } } string Path::Fixup ( const string& file, bool include_filename ) const { - if ( strchr ( "/\\", file[0] ) + if ( strchr ( "/\\", file[0] ) #ifdef WIN32 - // this squirreliness is b/c win32 has drive letters and *nix doesn't... - || file[1] == ':' + // this squirreliness is b/c win32 has drive letters and *nix doesn't... + || file[1] == ':' #endif//WIN32 - ) - { - return file; - } - vector<string> pathtmp ( path ); - vector<char> tmp = vectorize( file ); - const char* prev = strtok ( &tmp[0], "/\\" ); - const char* p = strtok ( NULL, "/\\" ); - while ( p ) - { - if ( !strcmp ( prev, "." ) ) - ; // do nothing - else if ( !strcmp ( prev, ".." ) ) - { - // this squirreliness is b/c win32 has drive letters and *nix doesn't... + ) + { + return file; + } + vector<string> pathtmp ( path ); + vector<char> tmp = vectorize( file ); + const char* prev = strtok ( &tmp[0], "/\\" ); + const char* p = strtok ( NULL, "/\\" ); + while ( p ) + { + if ( !strcmp ( prev, "." ) ) + ; // do nothing + else if ( !strcmp ( prev, ".." ) ) + { + // this squirreliness is b/c win32 has drive letters and *nix doesn't... #ifdef WIN32 - if ( pathtmp.size() > 1 ) + if ( pathtmp.size() > 1 ) #else - if ( pathtmp.size() ) + if ( pathtmp.size() ) #endif - pathtmp.resize ( pathtmp.size() - 1 ); - } - else - pathtmp.push_back ( prev ); - prev = p; - p = strtok ( NULL, "/\\" ); - } - if ( include_filename ) - pathtmp.push_back ( prev ); - - // reuse tmp variable to return recombined path - tmp = vectorize(""); - for ( size_t i = 0; i < pathtmp.size(); i++ ) - { - // this squirreliness is b/c win32 has drive letters and *nix doesn't... + pathtmp.resize ( pathtmp.size() - 1 ); + } + else + pathtmp.push_back ( prev ); + prev = p; + p = strtok ( NULL, "/\\" ); + } + if ( include_filename ) + pathtmp.push_back ( prev ); + + // reuse tmp variable to return recombined path + tmp = vectorize(""); + for ( size_t i = 0; i < pathtmp.size(); i++ ) + { + // this squirreliness is b/c win32 has drive letters and *nix doesn't... #ifdef WIN32 - if ( i ) vectappend(tmp, "/"); + if ( i ) vectappend(tmp, "/"); #else - vectappend(tmp, "/"); + vectappend(tmp, "/"); #endif - vectappend(tmp, pathtmp[i]); - } - return &tmp[0]; + vectappend(tmp, pathtmp[i]); + } + return &tmp[0]; } string Path::RelativeFromWorkingDirectory () { - string out = ""; - for ( size_t i = 0; i < path.size(); i++ ) - { - out += "/" + path[i]; - } - return RelativeFromWorkingDirectory ( out ); + string out = ""; + for ( size_t i = 0; i < path.size(); i++ ) + { + out += "/" + path[i]; + } + return RelativeFromWorkingDirectory ( out ); } string Path::RelativeFromWorkingDirectory ( const string& path ) { - return Path::RelativeFromDirectory ( path, working_directory ); + return Path::RelativeFromDirectory ( path, working_directory ); } string Path::RelativeFromDirectory ( - const string& path, - const string& base_directory ) -{ - vector<string> vbase, vpath, vout; - Path::Split ( vbase, base_directory, true ); - Path::Split ( vpath, path, true ); + const string& path, + const string& base_directory ) +{ + vector<string> vbase, vpath, vout; + Path::Split ( vbase, base_directory, true ); + Path::Split ( vpath, path, true ); #ifdef WIN32 - // this squirreliness is b/c win32 has drive letters and *nix doesn't... - // not possible to do relative across different drive letters - { - char path_driveletter = (path[1] == ':') ? toupper(path[0]) : 0; - char base_driveletter = (base_directory[1] == ':') ? toupper(base_directory[0]) : 0; - if ( path_driveletter != base_driveletter ) - return path; - } + // this squirreliness is b/c win32 has drive letters and *nix doesn't... + // not possible to do relative across different drive letters + { + char path_driveletter = (path[1] == ':') ? toupper(path[0]) : 0; + char base_driveletter = (base_directory[1] == ':') ? toupper(base_directory[0]) : 0; + if ( path_driveletter != base_driveletter ) + return path; + } #endif - size_t i = 0; - while ( i < vbase.size() && i < vpath.size() && vbase[i] == vpath[i] ) - ++i; - - // did we go through all of the path? - if ( vbase.size() == vpath.size() && i == vpath.size() ) - return "."; - - if ( i < vbase.size() ) - { - // path goes above our base directory, we will need some ..'s - for ( size_t j = i; j < vbase.size(); j++ ) - vout.push_back ( ".." ); - } - - while ( i < vpath.size() ) - vout.push_back ( vpath[i++] ); - - // now merge vout into a string again - string out = vout[0]; - for ( i = 1; i < vout.size(); i++ ) - { - out += "/" + vout[i]; - } - return out; + size_t i = 0; + while ( i < vbase.size() && i < vpath.size() && vbase[i] == vpath[i] ) + ++i; + + // did we go through all of the path? + if ( vbase.size() == vpath.size() && i == vpath.size() ) + return "."; + + if ( i < vbase.size() ) + { + // path goes above our base directory, we will need some ..'s + for ( size_t j = i; j < vbase.size(); j++ ) + vout.push_back ( ".." ); + } + + while ( i < vpath.size() ) + vout.push_back ( vpath[i++] ); + + // now merge vout into a string again + string out = vout[0]; + for ( i = 1; i < vout.size(); i++ ) + { + out += "/" + vout[i]; + } + return out; } void Path::Split ( - vector<string>& out, - const string& path, - bool include_last ) -{ - string s ( path ); - const char* prev = strtok ( &s[0], "/\\" ); - const char* p = strtok ( NULL, "/\\" ); - out.resize ( 0 ); - while ( p ) - { - if ( strcmp ( prev, "." ) ) - out.push_back ( prev ); - prev = p; - p = strtok ( NULL, "/\\" ); - } - if ( include_last && strcmp ( prev, "." ) ) - out.push_back ( prev ); - // special-case where path only has "." - // don't move this check up higher as it might miss - // some funny paths... - if ( !out.size() && !strcmp ( prev, "." ) ) - out.push_back ( "." ); + vector<string>& out, + const string& path, + bool include_last ) +{ + string s ( path ); + const char* prev = strtok ( &s[0], "/\\" ); + const char* p = strtok ( NULL, "/\\" ); + out.resize ( 0 ); + while ( p ) + { + if ( strcmp ( prev, "." ) ) + out.push_back ( prev ); + prev = p; + p = strtok ( NULL, "/\\" ); + } + if ( include_last && strcmp ( prev, "." ) ) + out.push_back ( prev ); + // special-case where path only has "." + // don't move this check up higher as it might miss + // some funny paths... + if ( !out.size() && !strcmp ( prev, "." ) ) + out.push_back ( "." ); } XMLFile::XMLFile() @@ -322,26 +322,26 @@ void XMLFile::close() { - _buf.resize(0); - _p = _end = NULL; + _buf.resize(0); + _p = _end = NULL; } bool XMLFile::open ( const string& filename_ ) { - close(); - FILE* f = fopen ( filename_.c_str(), "rb" ); - if ( !f ) - return false; - unsigned long len = (unsigned long)filelen(f); - _buf.resize ( len ); - fread ( &_buf[0], 1, len, f ); - fclose ( f ); - _p = _buf.c_str(); - _end = _p + len; - _filename = filename_; - next_token(); - return true; + close(); + FILE* f = fopen ( filename_.c_str(), "rb" ); + if ( !f ) + return false; + unsigned long len = (unsigned long)filelen(f); + _buf.resize ( len ); + fread ( &_buf[0], 1, len, f ); + fclose ( f ); + _p = _buf.c_str(); + _end = _p + len; + _filename = filename_; + next_token(); + return true; } // next_token() moves the pointer to next token, which may be @@ -351,19 +351,19 @@ void XMLFile::next_token() { - _p += strspn ( _p, WS ); + _p += strspn ( _p, WS ); } bool XMLFile::next_is_text() { - return *_p != '<'; + return *_p != '<'; } bool XMLFile::more_tokens () { - return _p != _end; + return _p != _end; } // get_token() is used to return a token, and move the pointer @@ -371,65 +371,65 @@ bool XMLFile::get_token ( string& token ) { - const char* tokend; - if ( !strncmp ( _p, "<!--", 4 ) ) - { - tokend = strstr ( _p, "-->" ); - if ( !tokend ) - tokend = _end; - else - tokend += 3; - } - else if ( !strncmp ( _p, "<?", 2 ) ) - { - tokend = strstr ( _p, "?>" ); - if ( !tokend ) - tokend = _end; - else - tokend += 2; - } - else if ( *_p == '<' ) - { - tokend = strchr ( _p, '>' ); - if ( !tokend ) - tokend = _end; - else - ++tokend; - } - else - { - tokend = strchr ( _p, '<' ); - if ( !tokend ) - tokend = _end; - while ( tokend > _p && isspace(tokend[-1]) ) - --tokend; - } - if ( tokend == _p ) - return false; - token = string ( _p, tokend-_p ); - _p = tokend; - next_token(); - return true; + const char* tokend; + if ( !strncmp ( _p, "<!--", 4 ) ) + { + tokend = strstr ( _p, "-->" ); + if ( !tokend ) + tokend = _end; + else + tokend += 3; + } + else if ( !strncmp ( _p, "<?", 2 ) ) + { + tokend = strstr ( _p, "?>" ); + if ( !tokend ) + tokend = _end; + else + tokend += 2; + } + else if ( *_p == '<' ) + { + tokend = strchr ( _p, '>' ); + if ( !tokend ) + tokend = _end; + else + ++tokend; + } + else + { + tokend = strchr ( _p, '<' ); + if ( !tokend ) + tokend = _end; + while ( tokend > _p && isspace(tokend[-1]) ) + --tokend; + } + if ( tokend == _p ) + return false; + token = string ( _p, tokend-_p ); + _p = tokend; + next_token(); + return true; } bool XMLFile::get_token ( string& token, string& location ) { - location = Location(); - return get_token ( token ); + location = Location(); + return get_token ( token ); } string XMLFile::Location() const { - int line = 1; - const char* p = strchr ( _buf.c_str(), '\n' ); - while ( p && p < _p ) - { - ++line; - p = strchr ( p+1, '\n' ); - } - return ssprintf ( "%s(%i)",_filename.c_str(), line ); + int line = 1; + const char* p = strchr ( _buf.c_str(), '\n' ); + while ( p && p < _p ) + { + ++line; + p = strchr ( p+1, '\n' ); + } + return ssprintf ( "%s(%i)",_filename.c_str(), line ); } XMLAttribute::XMLAttribute() @@ -437,48 +437,48 @@ } XMLAttribute::XMLAttribute( - const string& name_, - const string& value_ ) - : name(name_), value(value_) + const string& name_, + const string& value_ ) + : name(name_), value(value_) { } XMLAttribute::XMLAttribute ( const XMLAttribute& src ) - : name(src.name), value(src.value) + : name(src.name), value(src.value) { } XMLAttribute& XMLAttribute::operator = ( const XMLAttribute& src ) { - name = src.name; - value = src.value; - return *this; + name = src.name; + value = src.value; + return *this; } XMLElement::XMLElement ( - XMLFile* xmlFile, - const string& location ) - : xmlFile ( xmlFile ), - location ( location ), - parentElement ( NULL ) + XMLFile* xmlFile, + const string& location ) + : xmlFile ( xmlFile ), + location ( location ), + parentElement ( NULL ) { } XMLElement::~XMLElement() { - size_t i; - for ( i = 0; i < attributes.size(); i++ ) - delete attributes[i]; - for ( i = 0; i < subElements.size(); i++ ) - delete subElements[i]; + size_t i; + for ( i = 0; i < attributes.size(); i++ ) + delete attributes[i]; + for ( i = 0; i < subElements.size(); i++ ) + delete subElements[i]; } void XMLElement::AddSubElement ( XMLElement* e ) { - subElements.push_back ( e ); - e->parentElement = this; + subElements.push_back ( e ); + e->parentElement = this; } // Parse() @@ -489,171 +489,171 @@ // the one it just parsed... bool XMLElement::Parse ( - const string& token, - bool& end_tag ) -{ - const char* p = token.c_str(); - assert ( *p == '<' ); - ++p; - p += strspn ( p, WS ); - - // check if this is a comment - if ( !strncmp ( p, "!--", 3 ) ) - { - name = "!--"; - end_tag = false; - return false; // never look for end tag to a comment - } - - end_tag = ( *p == '/' ); - if ( end_tag ) - { - ++p; - p += strspn ( p, WS ); - } - const char* end = strpbrk ( p, WS ); - if ( !end ) - { - end = strpbrk ( p, "/>" ); - assert ( end ); - } - name = string ( p, end-p ); - p = end; - p += strspn ( p, WS ); - while ( *p != '>' && *p != '/' ) - { - end = strpbrk ( p, WSEQ ); - if ( !end ) - { - end = strpbrk ( p, "/>" ); - assert ( end ); - } - string attribute ( p, end-p ), value; - p = end; - p += strspn ( p, WS ); - if ( *p == '=' ) - { - ++p; - p += strspn ( p, WS ); - char quote = 0; - if ( strchr ( "\"'", *p ) ) - { - quote = *p++; - end = strchr ( p, quote ); - } - else - { - end = strpbrk ( p, WS ); - } - if ( !end ) - { - end = strchr ( p, '>' ); - assert(end); - if ( end[-1] == '/' ) - end--; - } - value = string ( p, end-p ); - p = end; - if ( quote && *p == quote ) - p++; - p += strspn ( p, WS ); - } - else if ( name[0] != '!' ) - { - throw XMLSyntaxErrorException ( - location, - "attributes must have values" ); - } - attributes.push_back ( new XMLAttribute ( attribute, value ) ); - } - return !( *p == '/' ) && !end_tag; + const string& token, + bool& end_tag ) +{ + const char* p = token.c_str(); + assert ( *p == '<' ); + ++p; + p += strspn ( p, WS ); + + // check if this is a comment + if ( !strncmp ( p, "!--", 3 ) ) + { + name = "!--"; + end_tag = false; + return false; // never look for end tag to a comment + } + + end_tag = ( *p == '/' ); + if ( end_tag ) + { + ++p; + p += strspn ( p, WS ); + } + const char* end = strpbrk ( p, WS ); + if ( !end ) + { + end = strpbrk ( p, "/>" ); + assert ( end ); + } + name = string ( p, end-p ); + p = end; + p += strspn ( p, WS ); + while ( *p != '>' && *p != '/' ) + { + end = strpbrk ( p, WSEQ ); + if ( !end ) + { + end = strpbrk ( p, "/>" ); + assert ( end ); + } + string attribute ( p, end-p ), value; + p = end; + p += strspn ( p, WS ); + if ( *p == '=' ) + { + ++p; + p += strspn ( p, WS ); + char quote = 0; + if ( strchr ( "\"'", *p ) ) + { + quote = *p++; + end = strchr ( p, quote ); + } + else + { + end = strpbrk ( p, WS ); + } + if ( !end ) + { + end = strchr ( p, '>' ); + assert(end); + if ( end[-1] == '/' ) + end--; + } + value = string ( p, end-p ); + p = end; + if ( quote && *p == quote ) + p++; + p += strspn ( p, WS ); + } + else if ( name[0] != '!' ) + { + throw XMLSyntaxErrorException ( + location, + "attributes must have values" ); + } + attributes.push_back ( new XMLAttribute ( attribute, value ) ); + } + return !( *p == '/' ) && !end_tag; } XMLAttribute* XMLElement::GetAttribute ( - const string& attribute, - bool required ) -{ - // this would be faster with a tree-based container, but our attribute - // lists are likely to stay so short as to not be an issue. - for ( size_t i = 0; i < attributes.size(); i++ ) - { - if ( attribute == attributes[i]->name ) - return attributes[i]; - } - if ( required ) - { - throw XMLRequiredAttributeNotFoundException ( - location, - attribute, - name ); - } - return NULL; + const string& attribute, + bool required ) +{ + // this would be faster with a tree-based container, but our attribute + // lists are likely to stay so short as to not be an issue. + for ( size_t i = 0; i < attributes.size(); i++ ) + { + if ( attribute == attributes[i]->name ) + return attributes[i]; + } + if ( required ) + { + throw XMLRequiredAttributeNotFoundException ( + location, + attribute, + name ); + } + return NULL; } const XMLAttribute* XMLElement::GetAttribute ( - const string& attribute, - bool required ) const -{ - // this would be faster with a tree-based container, but our attribute - // lists are likely to stay so short as to not be an issue. - for ( size_t i = 0; i < attributes.size(); i++ ) - { - if ( attribute == attributes[i]->name ) - return attributes[i]; - } - if ( required ) - { - throw XMLRequiredAttributeNotFoundException ( - location, - attribute, - name ); - } - return NULL; + const string& attribute, + bool required ) const +{ + // this would be faster with a tree-based container, but our attribute + // lists are likely to stay so short as to not be an issue. + for ( size_t i = 0; i < attributes.size(); i++ ) + { + if ( attribute == attributes[i]->name ) + return attributes[i]; + } + if ( required ) + { + throw XMLRequiredAttributeNotFoundException ( + location, + attribute, + name ); + } + return NULL; } int XMLElement::FindElement ( const std::string& type, int prev ) const { - int done = subElements.size(); - while ( ++prev < done ) - { - XMLElement* e = subElements[prev]; - if ( e->name == type ) - return prev; - } - return -1; + int done = subElements.size(); + while ( ++prev < done ) + { + XMLElement* e = subElements[prev]; + if ( e->name == type ) + return prev; + } + return -1; } int XMLElement::GetElements ( - const std::string& type, - std::vector<XMLElement*>& v ) -{ - int find = FindElement ( type ); - v.resize ( 0 ); - while ( find != -1 ) - { - v.push_back ( subElements[find] ); - find = FindElement ( type, find ); - } - return v.size(); + const std::string& type, + std::vector<XMLElement*>& v ) +{ + int find = FindElement ( type ); + v.resize ( 0 ); + while ( find != -1 ) + { + v.push_back ( subElements[find] ); + find = FindElement ( type, find ); + } + return v.size(); } int XMLElement::GetElements ( - const std::string& type, - std::vector<const XMLElement*>& v ) const -{ - int find = FindElement ( type ); - v.resize ( 0 ); - while ( find != -1 ) - { - v.push_back ( subElements[find] ); - find = FindElement ( type, find ); - } - return v.size(); + const std::string& type, + std::vector<const XMLElement*>& v ) const +{ + int find = FindElement ( type ); + v.resize ( 0 ); + while ( find != -1 ) + { + v.push_back ( subElements[find] ); + find = FindElement ( type, find ); + } + return v.size(); } // XMLParse() @@ -665,301 +665,301 @@ // (no more data) XMLElement* XMLParse ( - XMLFile& f, - XMLIncludes* includes, - const Path& path, - bool* pend_tag = NULL ) -{ - string token, location; - if ( !f.get_token(token,location) ) - return NULL; - bool end_tag, is_include = false; - - while - ( - token[0] != '<' - || !strncmp ( token.c_str (), "<!--", 4 ) - || !strncmp ( token.c_str (), "<?", 2 ) - ) - { - if ( token[0] != '<' ) - { - throw XMLSyntaxErrorException ( - location, - "expecting xml tag, not '%s'", - token.c_str () ); - } - if ( !f.get_token ( token, location ) ) - return NULL; - } - - XMLElement* e = new XMLElement ( - &f, - location ); - bool bNeedEnd = e->Parse ( token, end_tag ); - - if ( e->name == "xi:include" && includes ) - { - XMLAttribute* att; - att = e->GetAttribute ( "href", true ); - assert ( att ); - string includeFile ( path.Fixup ( att->value, true ) ); - string topIncludeFile ( - Path::RelativeFromWorkingDirectory ( includeFile ) ); - includes->push_back ( - new XMLInclude ( e, path, topIncludeFile ) ); - is_include = true; - } - - if ( !bNeedEnd ) - { - if ( pend_tag ) - *pend_tag = end_tag; - else if ( end_tag ) - { - delete e; - throw XMLSyntaxErrorException ( - location, - "end tag '%s' not expected", - token.c_str() ); - return NULL; - } - return e; - } - bool bThisMixingErrorReported = false; - while ( f.more_tokens () ) - { - if ( f.next_is_text () ) - { - if ( !f.get_token ( token, location ) || token.size () == 0 ) - { - throw XMLInvalidBuildFileException ( - location, - "internal tool error - get_token() failed when more_tokens() returned true" ); - break; - } - if ( e->subElements.size() && !bThisMixingErrorReported ) - { - throw XMLSyntaxErrorException ( - location, - "mixing of inner text with sub elements" ); - bThisMixingErrorReported = true; - } - if ( strchr ( token.c_str (), '>' ) ) - { - throw XMLSyntaxErrorException ( - location, - "invalid symbol '>'" ); - } - if ( e->value.size() > 0 ) - { - throw XMLSyntaxErrorException ( - location, - "multiple instances of inner text" ); - e->value += " " + token; - } - else - e->value = token; - } - else - { - XMLElement* e2 = XMLParse ( - f, is_include ? NULL : includes, path, &end_tag ); - if ( !e2 ) - { - string e_location = e->location; - string e_name = e->name; - delete e; - throw XMLInvalidBuildFileException ( - e_location, - "end of file found looking for end tag: </%s>", - e_name.c_str() ); - break; - } - if ( end_tag ) - { - if ( e->name != e2->name ) - { - string e2_location = e2->location; - string e_name = e->name; - string e2_name = e2->name; - delete e; - delete e2; - throw XMLSyntaxErrorException ( - e2_location, - "end tag name mismatch - found </%s> but was expecting </%s>", - e2_name.c_str(), - e_name.c_str() ); - break; - } - delete e2; - break; - } - if ( e->value.size () > 0 && !bThisMixingErrorReported ) - { - string e_location = e->location; - delete e; - throw XMLSyntaxErrorException ( - e_location, - "mixing of inner text with sub elements" ); - bThisMixingErrorReported = true; - } - e->AddSubElement ( e2 ); - } - } - return e; + XMLFile& f, + XMLIncludes* includes, + const Path& path, + bool* pend_tag = NULL ) +{ + string token, location; + if ( !f.get_token(token,location) ) + return NULL; + bool end_tag, is_include = false; + + while + ( + token[0] != '<' + || !strncmp ( token.c_str (), "<!--", 4 ) + || !strncmp ( token.c_str (), "<?", 2 ) + ) + { + if ( token[0] != '<' ) + { + throw XMLSyntaxErrorException ( + location, + "expecting xml tag, not '%s'", + token.c_str () ); + } + if ( !f.get_token ( token, location ) ) + return NULL; + } + + XMLElement* e = new XMLElement ( + &f, + location ); + bool bNeedEnd = e->Parse ( token, end_tag ); + + if ( e->name == "xi:include" && includes ) + { + XMLAttribute* att; + att = e->GetAttribute ( "href", true ); + assert ( att ); + string includeFile ( path.Fixup ( att->value, true ) ); + string topIncludeFile ( + Path::RelativeFromWorkingDirectory ( includeFile ) ); + includes->push_back ( + new XMLInclude ( e, path, topIncludeFile ) ); + is_include = true; + } + + if ( !bNeedEnd ) + { + if ( pend_tag ) + *pend_tag = end_tag; + else if ( end_tag ) + { + delete e; + throw XMLSyntaxErrorException ( + location, + "end tag '%s' not expected", + token.c_str() ); + return NULL; + } + return e; + } + bool bThisMixingErrorReported = false; + while ( f.more_tokens () ) + { + if ( f.next_is_text () ) + { + if ( !f.get_token ( token, location ) || token.size () == 0 ) + { + throw XMLInvalidBuildFileException ( + location, + "internal tool error - get_token() failed when more_tokens() returned true" ); + break; + } + if ( e->subElements.size() && !bThisMixingErrorReported ) + { + throw XMLSyntaxErrorException ( + location, + "mixing of inner text with sub elements" ); + bThisMixingErrorReported = true; + } + if ( strchr ( token.c_str (), '>' ) ) + { + throw XMLSyntaxErrorException ( + location, + "invalid symbol '>'" ); + } + if ( e->value.size() > 0 ) + { + throw XMLSyntaxErrorException ( + location, + "multiple instances of inner text" ); + e->value += " " + token; + } + else + e->value = token; + } + else + { + XMLElement* e2 = XMLParse ( + f, is_include ? NULL : includes, path, &end_tag ); + if ( !e2 ) + { + string e_location = e->location; + string e_name = e->name; + delete e; + throw XMLInvalidBuildFileException ( + e_location, + "end of file found looking for end tag: </%s>", + e_name.c_str() ); + break; + } + if ( end_tag ) + { + if ( e->name != e2->name ) + { + string e2_location = e2->location; + string e_name = e->name; + string e2_name = e2->name; + delete e; + delete e2; + throw XMLSyntaxErrorException ( + e2_location, + "end tag name mismatch - found </%s> but was expecting </%s>", + e2_name.c_str(), + e_name.c_str() ); + break; + } + delete e2; + break; + } + if ( e->value.size () > 0 && !bThisMixingErrorReported ) + { + string e_location = e->location; + delete e; + throw XMLSyntaxErrorException ( + e_location, + "mixing of inner text with sub elements" ); + bThisMixingErrorReported = true; + } + e->AddSubElement ( e2 ); + } + } + return e; } void XMLReadFile ( - XMLFile& f, - XMLElement& head, - XMLIncludes& includes, - const Path& path ) -{ - for ( ;; ) - { - XMLElement* e = XMLParse ( f, &includes, path ); - if ( !e ) - return; - head.AddSubElement ( e ); - } + XMLFile& f, + XMLElement& head, + XMLIncludes& includes, + const Path& path ) +{ + for ( ;; ) + { + XMLElement* e = XMLParse ( f, &includes, path ); + if ( !e ) + return; + head.AddSubElement ( e ); + } } XMLElement* XMLLoadInclude ( - XMLInclude& include, - XMLIncludes& includes ) -{ - XMLAttribute* att; - att = include.e->GetAttribute("href", true); - assert(att); - - string file ( include.path.Fixup(att->value, true) ); - string top_file ( Path::RelativeFromWorkingDirectory ( file ) ); - include.e->attributes.push_back ( new XMLAttribute ( "top_href", top_file ) ); - XMLFile* fInc = new XMLFile(); - if ( !fInc->open ( file ) ) - { - include.fileExists = false; - // look for xi:fallback element - for ( size_t i = 0; i < include.e->subElements.size (); i++ ) - { - XMLElement* e2 = include.e->subElements[i]; - if ( e2->name == "xi:fallback" ) - { - // now look for xi:include below... - for ( i = 0; i < e2->subElements.size (); i++ ) - { - XMLElement* e3 = e2->subElements[i]; - if ( e3->name == "xi:include" ) - { - att = e3->GetAttribute ( "href", true ); - assert ( att ); - string includeFile ( - include.path.Fixup ( att->value, true ) ); - string topIncludeFile ( - Path::RelativeFromWorkingDirectory ( includeFile ) ); - XMLInclude* fallbackInclude = - new XMLInclude ( e3, include.path, topIncludeFile ); - - XMLElement* value = XMLLoadInclude (*fallbackInclude, includes ); - delete fallbackInclude; - return value; - } - } - throw XMLInvalidBuildFileException ( - e2->location, - "<xi:fallback> must have a <xi:include> sub-element" ); - return NULL; - } - } - return NULL; - } - else - { - include.fileExists = true; - XMLElement* new_e = new XMLElement ( - fInc, - include.e->location ); - new_e->name = "xi:included"; - Path path2 ( include.path, att->value ); - XMLReadFile ( *fInc, *new_e, includes, path2 ); - return new_e; - } + XMLInclude& include, + XMLIncludes& includes ) +{ + XMLAttribute* att; + att = include.e->GetAttribute("href", true); + assert(att); + + string file ( include.path.Fixup(att->value, true) ); + string top_file ( Path::RelativeFromWorkingDirectory ( file ) ); + include.e->attributes.push_back ( new XMLAttribute ( "top_href", top_file ) ); + XMLFile* fInc = new XMLFile(); + if ( !fInc->open ( file ) ) + { + include.fileExists = false; + // look for xi:fallback element + for ( size_t i = 0; i < include.e->subElements.size (); i++ ) + { + XMLElement* e2 = include.e->subElements[i]; + if ( e2->name == "xi:fallback" ) + { + // now look for xi:include below... + for ( i = 0; i < e2->subElements.size (); i++ ) + { + XMLElement* e3 = e2->subElements[i]; + if ( e3->name == "xi:include" ) + { + att = e3->GetAttribute ( "href", true ); + assert ( att ); + string includeFile ( + include.path.Fixup ( att->value, true ) ); + string topIncludeFile ( + Path::RelativeFromWorkingDirectory ( includeFile ) ); + XMLInclude* fallbackInclude = + new XMLInclude ( e3, include.path, topIncludeFile ); + + XMLElement* value = XMLLoadInclude (*fallbackInclude, includes ); + delete fallbackInclude; + return value; + } + } + throw XMLInvalidBuildFileException ( + e2->location, + "<xi:fallback> must have a <xi:include> sub-element" ); + return NULL; + } + } + return NULL; + } + else + { + include.fileExists = true; + XMLElement* new_e = new XMLElement ( + fInc, + include.e->location ); + new_e->name = "xi:included"; + Path path2 ( include.path, att->value ); + XMLReadFile ( *fInc, *new_e, includes, path2 ); + return new_e; + } } XMLElement* XMLLoadFile ( - const string& filename, - const Path& path, - XMLIncludes& includes ) -{ - XMLFile* f = new XMLFile(); - - if ( !f->open ( filename ) ) - { - delete f; - throw XMLFileNotFoundException ( "(virtual)", filename ); - return NULL; - } - - XMLElement* head = new XMLElement ( f, "(virtual)" ); - - XMLReadFile ( *f, *head, includes, path ); - - for ( size_t i = 0; i < includes.size (); i++ ) - { - XMLElement* e = includes[i]->e; - XMLElement* e2 = XMLLoadInclude ( *includes[i], includes ); - if ( !e2 ) - { - throw XMLFileNotFoundException ( - f->Location(), - e->GetAttribute ( "top_href", true )->value ); - } - XMLElement* parent = e->parentElement; - XMLElement** parent_container = NULL; - if ( !parent ) - { - string location = e->location; - delete e; - delete f; - throw XMLException ( location, "internal tool error: xi:include doesn't have a parent" ); - return NULL; - } - for ( size_t j = 0; j < parent->subElements.size (); j++ ) - { - if ( parent->subElements[j] == e ) - { - parent_container = &parent->subElements[j]; - break; - } - } - if ( !parent_container ) - { - string location = e->location; - delete e; - delete f; - throw XMLException ( location, "internal tool error: couldn't find xi:include in parent's sub-elements" ); - return NULL; - } - // replace inclusion tree with the imported tree - e2->parentElement = e->parentElement; - e2->name = e->name; - e2->attributes = e->attributes; - *parent_container = e2; - e->attributes.resize ( 0 ); - delete e; - } - delete f; - return head; + const string& filename, + const Path& path, + XMLIncludes& includes ) +{ + XMLFile* f = new XMLFile(); + + if ( !f->open ( filename ) ) + { + delete f; + throw XMLFileNotFoundException ( "(virtual)", filename ); + return NULL; + } + + XMLElement* head = new XMLElement ( f, "(virtual)" ); + + XMLReadFile ( *f, *head, includes, path ); + + for ( size_t i = 0; i < includes.size (); i++ ) + { + XMLElement* e = includes[i]->e; + XMLElement* e2 = XMLLoadInclude ( *includes[i], includes ); + if ( !e2 ) + { + throw XMLFileNotFoundException ( + f->Location(), + e->GetAttribute ( "top_href", true )->value ); + } + XMLElement* parent = e->parentElement; + XMLElement** parent_container = NULL; + if ( !parent ) + { + string location = e->location; + delete e; + delete f; + throw XMLException ( location, "internal tool error: xi:include doesn't have a parent" ); + return NULL; + } + for ( size_t j = 0; j < parent->subElements.size (); j++ ) + { + if ( parent->subElements[j] == e ) + { + parent_container = &parent->subElements[j]; + break; + } + } + if ( !parent_container ) + { + string location = e->location; + delete e; + delete f; + throw XMLException ( location, "internal tool error: couldn't find xi:include in parent's sub-elements" ); + return NULL; + } + // replace inclusion tree with the imported tree + e2->parentElement = e->parentElement; + e2->name = e->name; + e2->attributes = e->attributes; + *parent_container = e2; + e->attributes.resize ( 0 ); + delete e; + } + delete f; + return head; } XMLElement* XMLLoadFile ( const string& filename ) { - Path path; - XMLIncludes includes; - return XMLLoadFile ( filename, path, includes ); -} + Path path; + XMLIncludes includes; + return XMLLoadFile ( filename, path, includes ); +}
15 years, 10 months
1
0
0
0
[arty] 39218: Fix misuse of std::string in assuming that it's always null terminated, and that the c_str result is writable.
by arty@svn.reactos.org
Author: arty Date: Sat Jan 31 02:43:10 2009 New Revision: 39218 URL:
http://svn.reactos.org/svn/reactos?rev=39218&view=rev
Log: Fix misuse of std::string in assuming that it's always null terminated, and that the c_str result is writable. Modified: trunk/reactos/tools/xml.cpp trunk/reactos/tools/xml.h Modified: trunk/reactos/tools/xml.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/xml.cpp?rev=39218&r1…
============================================================================== --- trunk/reactos/tools/xml.cpp [iso-8859-1] (original) +++ trunk/reactos/tools/xml.cpp [iso-8859-1] Sat Jan 31 02:43:10 2009 @@ -58,6 +58,35 @@ string working_directory; +std::vector<char> vectorize(const std::string &str) +{ + std::vector<char> result( str.size() + 1 ); + strcpy( &result[0], str.c_str() ); + return result; +} + +void vectappend(std::vector<char> &strvec, const char *str) +{ + if (*str) { strvec[strlen(&strvec[0])] = *str; str++; } + while (*str) + { + strvec.push_back(*str); + str++; + } + strvec.push_back(0); +} + +void vectappend(std::vector<char> &strvec, const std::string &str) +{ + vectappend(strvec, str.c_str()); +} + +void vectappend(std::vector<char> &strvec, char ch) +{ + strvec[strlen(&strvec[0])] = ch; + strvec.push_back(0); +} + XMLException::XMLException ( const std::string& location, const char* format, ... ) @@ -158,7 +187,7 @@ return file; } vector<string> pathtmp ( path ); - string tmp ( file ); + vector<char> tmp = vectorize( file ); const char* prev = strtok ( &tmp[0], "/\\" ); const char* p = strtok ( NULL, "/\\" ); while ( p ) @@ -184,18 +213,18 @@ pathtmp.push_back ( prev ); // reuse tmp variable to return recombined path - tmp.resize(0); + tmp = vectorize(""); for ( size_t i = 0; i < pathtmp.size(); i++ ) { // this squirreliness is b/c win32 has drive letters and *nix doesn't... #ifdef WIN32 - if ( i ) tmp += "/"; + if ( i ) vectappend(tmp, "/"); #else - tmp += "/"; + vectappend(tmp, "/"); #endif - tmp += pathtmp[i]; - } - return tmp; + vectappend(tmp, pathtmp[i]); + } + return &tmp[0]; } string Modified: trunk/reactos/tools/xml.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/xml.h?rev=39218&r1=3…
============================================================================== --- trunk/reactos/tools/xml.h [iso-8859-1] (original) +++ trunk/reactos/tools/xml.h [iso-8859-1] Sat Jan 31 02:43:10 2009 @@ -236,4 +236,9 @@ XMLElement* XMLLoadFile ( const std::string& filename ); +std::vector<char> vectorize(const std::string &str); +void vectappend(std::vector<char> &strvec, char ch); +void vectappend(std::vector<char> &strvec, const char *charstr); +void vectappend(std::vector<char> &strvec, const std::string &str); + #endif // XML_H
15 years, 10 months
1
0
0
0
[gschneider] 39217: Unify identical StretchBlt implementations in preparation of partial ROP suppport.
by gschneider@svn.reactos.org
Author: gschneider Date: Fri Jan 30 14:02:58 2009 New Revision: 39217 URL:
http://svn.reactos.org/svn/reactos?rev=39217&view=rev
Log: Unify identical StretchBlt implementations in preparation of partial ROP suppport. Modified: trunk/reactos/subsystems/win32/win32k/dib/dib16bpp.c trunk/reactos/subsystems/win32/win32k/dib/dib1bpp.c trunk/reactos/subsystems/win32/win32k/dib/dib24bpp.c trunk/reactos/subsystems/win32/win32k/dib/dib32bpp.c trunk/reactos/subsystems/win32/win32k/dib/dib4bpp.c trunk/reactos/subsystems/win32/win32k/dib/dib8bpp.c Modified: trunk/reactos/subsystems/win32/win32k/dib/dib16bpp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/di…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/dib/dib16bpp.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/dib/dib16bpp.c [iso-8859-1] Fri Jan 30 14:02:58 2009 @@ -781,13 +781,10 @@ sy_max = DesSizeY; sy = SourceRect->top; - switch(SourceSurf->iBitmapFormat) - { - - case BMF_1BPP: + if (SourceSurf->iBitmapFormat != BMF_16BPP) + { /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ /* This is a reference implementation, it hasn't been optimized for speed */ - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) { sx = SourceRect->left; @@ -796,7 +793,8 @@ for (DesX=DestRect->left; DesX<DestRect->right; DesX++) { color = XLATEOBJ_iXlate(ColorTranslation, - DIB_1BPP_GetPixel(SourceSurf, sx, sy)); + DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat]. + DIB_GetPixel(SourceSurf, sx, sy)); DIB_16BPP_PutPixel(DestSurf, DesX, DesY, color); @@ -817,162 +815,13 @@ sy_dec -= sy_max; } } - break; - - case BMF_4BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_4BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_16BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_8BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_8BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_16BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - - case BMF_24BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_24BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_16BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_32BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_32BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_16BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_16BPP: + } + else + { return ScaleRectAvg16(DestSurf, SourceSurf, DestRect, SourceRect, MaskOrigin, BrushOrigin, ClipRegion, ColorTranslation, Mode); - break; - - default: - DPRINT1("DIB_16BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat)); - return FALSE; - } - - - - return TRUE; + } + return TRUE; } BOOLEAN Modified: trunk/reactos/subsystems/win32/win32k/dib/dib1bpp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/di…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/dib/dib1bpp.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/dib/dib1bpp.c [iso-8859-1] Fri Jan 30 14:02:58 2009 @@ -516,118 +516,21 @@ DesSizeY = DestRect->bottom - DestRect->top; DesSizeX = DestRect->right - DestRect->left; - switch(SourceSurf->iBitmapFormat) - { - case BMF_1BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - - color = DIB_1BPP_GetPixel(SourceSurf, sx, sy); - DIB_1BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); - } - } - - break; - - case BMF_4BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - color = DIB_4BPP_GetPixel(SourceSurf, sx, sy); - DIB_1BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); - } - } - break; - - case BMF_8BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - color = DIB_8BPP_GetPixel(SourceSurf, sx, sy); - DIB_1BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); - } - } - break; - - case BMF_16BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - color = DIB_16BPP_GetPixel(SourceSurf, sx, sy); - DIB_1BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); - } - } - break; - - case BMF_24BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - color = DIB_24BPP_GetPixel(SourceSurf, sx, sy); - DIB_1BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); - } - } - break; - - case BMF_32BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - color = DIB_32BPP_GetPixel(SourceSurf, sx, sy); - DIB_1BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); - } - } - break; - - default: - DPRINT1("DIB_1BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat)); - return FALSE; + /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ + /* This is a reference implementation, it hasn't been optimized for speed */ + for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) + { + sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; + + for (DesX=DestRect->left; DesX<DestRect->right; DesX++) + { + sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; + color = DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat]. + DIB_GetPixel(SourceSurf, sx, sy); + DIB_1BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); + } } - - return TRUE; + return TRUE; } BOOLEAN Modified: trunk/reactos/subsystems/win32/win32k/dib/dib24bpp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/di…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/dib/dib24bpp.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/dib/dib24bpp.c [iso-8859-1] Fri Jan 30 14:02:58 2009 @@ -459,225 +459,39 @@ sy_max = DesSizeY; sy = SourceRect->top; - switch(SourceSurf->iBitmapFormat) - { - case BMF_1BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) + /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ + /* This is a reference implementation, it hasn't been optimized for speed */ + for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) + { + sx = SourceRect->left; + sx_dec = 0; + + for (DesX=DestRect->left; DesX<DestRect->right; DesX++) + { + color = XLATEOBJ_iXlate(ColorTranslation, + DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat]. + DIB_GetPixel(SourceSurf, sx, sy)); + + DIB_24BPP_PutPixel(DestSurf, DesX, DesY, color); + + sx += SrcZoomXHight; + sx_dec += SrcZoomXLow; + if (sx_dec >= sx_max) { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_1BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_24BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } + sx++; + sx_dec -= sx_max; } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - - break; - - case BMF_4BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_4BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_24BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_8BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_8BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_24BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_16BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_16BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_24BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_24BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_24BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_24BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_32BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_32BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_24BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - default: - DPRINT1("DIB_24BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat)); - return FALSE; + } + + sy += SrcZoomYHight; + sy_dec += SrcZoomYLow; + if (sy_dec >= sy_max) + { + sy++; + sy_dec -= sy_max; + } } - - return TRUE; + return TRUE; } BOOLEAN Modified: trunk/reactos/subsystems/win32/win32k/dib/dib32bpp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/di…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/dib/dib32bpp.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/dib/dib32bpp.c [iso-8859-1] Fri Jan 30 14:02:58 2009 @@ -539,9 +539,8 @@ DifflDelta = DestSurf->lDelta - (DesSizeX << 2); - switch(SourceSurf->iBitmapFormat) + if (SourceSurf->iBitmapFormat != BMF_32BPP) { - case BMF_1BPP: /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ /* This is a reference implementation, it hasn't been optimized for speed */ for (DesY=0; DesY<DesSizeY; DesY++) @@ -551,7 +550,8 @@ for (DesX=0; DesX<DesSizeX; DesX++) { *DestBits = XLATEOBJ_iXlate(ColorTranslation, - DIB_1BPP_GetPixel(SourceSurf, sx, sy)); + DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat]. + DIB_GetPixel(SourceSurf, sx, sy)); DestBits = (PULONG)((ULONG_PTR)DestBits + 4); @@ -574,165 +574,13 @@ sy_dec -= sy_max; } } - break; - - case BMF_4BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=0; DesY<DesSizeY; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - for (DesX=0; DesX<DesSizeX; DesX++) - { - *DestBits = XLATEOBJ_iXlate(ColorTranslation, - DIB_4BPP_GetPixel(SourceSurf, sx, sy)); - - DestBits = (PULONG)((ULONG_PTR)DestBits + 4); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - DestBits = (PULONG)((ULONG_PTR)DestBits + DifflDelta); - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_8BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=0; DesY<DesSizeY; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - for (DesX=0; DesX<DesSizeX; DesX++) - { - *DestBits = XLATEOBJ_iXlate(ColorTranslation, - DIB_8BPP_GetPixel(SourceSurf, sx, sy)); - - DestBits = (PULONG)((ULONG_PTR)DestBits + 4); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - DestBits = (PULONG)((ULONG_PTR)DestBits + DifflDelta); - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_16BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=0; DesY<DesSizeY; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - for (DesX=0; DesX<DesSizeX; DesX++) - { - *DestBits = XLATEOBJ_iXlate(ColorTranslation, - DIB_16BPP_GetPixel(SourceSurf, sx, sy)); - - DestBits = (PULONG)((ULONG_PTR)DestBits + 4); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - DestBits = (PULONG)((ULONG_PTR)DestBits + DifflDelta); - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_24BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=0; DesY<DesSizeY; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - for (DesX=0; DesX<DesSizeX; DesX++) - { - *DestBits = XLATEOBJ_iXlate(ColorTranslation, - DIB_24BPP_GetPixel(SourceSurf, sx, sy)); - - DestBits = (PULONG)((ULONG_PTR)DestBits + 4); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - DestBits = (PULONG)((ULONG_PTR)DestBits + DifflDelta); - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_32BPP: + } + else + { return ScaleRectAvg32(DestSurf, SourceSurf, DestRect, SourceRect, MaskOrigin, BrushOrigin, ClipRegion, ColorTranslation, Mode); - break; - - default: - DPRINT1("DIB_32BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat)); - return FALSE; } - - - - return TRUE; + return TRUE; } BOOLEAN Modified: trunk/reactos/subsystems/win32/win32k/dib/dib4bpp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/di…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/dib/dib4bpp.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/dib/dib4bpp.c [iso-8859-1] Fri Jan 30 14:02:58 2009 @@ -397,124 +397,21 @@ DesSizeY = DestRect->bottom - DestRect->top; DesSizeX = DestRect->right - DestRect->left; - switch(SourceSurf->iBitmapFormat) - { - case BMF_1BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - - if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0) - { - DIB_4BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, 0)); - } - else - { - DIB_4BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, 1)); - } - } - } - - break; - - case BMF_4BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - color = DIB_4BPP_GetPixel(SourceSurf, sx, sy); - DIB_4BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); - } - } - break; - - case BMF_8BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - color = DIB_8BPP_GetPixel(SourceSurf, sx, sy); - DIB_4BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); - } - } - break; - - case BMF_16BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - color = DIB_16BPP_GetPixel(SourceSurf, sx, sy); - DIB_4BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); - } - } - break; - - case BMF_24BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - color = DIB_24BPP_GetPixel(SourceSurf, sx, sy); - DIB_4BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); - } - } - break; - - case BMF_32BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; - - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; - color = DIB_32BPP_GetPixel(SourceSurf, sx, sy); - DIB_4BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); - } - } - break; - - default: - DPRINT1("DIB_4BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat)); - return FALSE; - } - - return TRUE; + /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ + /* This is a reference implementation, it hasn't been optimized for speed */ + for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) + { + sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top; + + for (DesX=DestRect->left; DesX<DestRect->right; DesX++) + { + sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left; + color = DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat]. + DIB_GetPixel(SourceSurf, sx, sy); + DIB_4BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color)); + } + } + return TRUE; } BOOLEAN Modified: trunk/reactos/subsystems/win32/win32k/dib/dib8bpp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/di…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/dib/dib8bpp.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/dib/dib8bpp.c [iso-8859-1] Fri Jan 30 14:02:58 2009 @@ -517,11 +517,10 @@ sy_max = DesSizeY; sy = SourceRect->top; - switch(SourceSurf->iBitmapFormat) - { - case BMF_1BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ + if (SourceSurf->iBitmapFormat != BMF_8BPP) + { + /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ + /* This is a reference implementation, it hasn't been optimized for speed */ for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) { sx = SourceRect->left; @@ -529,7 +528,8 @@ for (DesX=DestRect->left; DesX<DestRect->right; DesX++) { color = XLATEOBJ_iXlate(ColorTranslation, - DIB_1BPP_GetPixel(SourceSurf, sx, sy)); + DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat]. + DIB_GetPixel(SourceSurf, sx, sy)); DIB_8BPP_PutPixel(DestSurf, DesX, DesY, color); @@ -550,151 +550,13 @@ sy_dec -= sy_max; } } - break; - - case BMF_4BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_4BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_8BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_8BPP: - return ScaleRectAvg8(DestSurf, SourceSurf, DestRect, SourceRect, MaskOrigin, BrushOrigin, + } + else + { + return ScaleRectAvg8(DestSurf, SourceSurf, DestRect, SourceRect, MaskOrigin, BrushOrigin, ClipRegion, ColorTranslation, Mode); - break; - - case BMF_16BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_16BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_8BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_24BPP: - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_24BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_8BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - case BMF_32BPP: - /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */ - /* This is a reference implementation, it hasn't been optimized for speed */ - for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++) - { - sx = SourceRect->left; - sx_dec = 0; - for (DesX=DestRect->left; DesX<DestRect->right; DesX++) - { - color = XLATEOBJ_iXlate(ColorTranslation, - DIB_32BPP_GetPixel(SourceSurf, sx, sy)); - - DIB_8BPP_PutPixel(DestSurf, DesX, DesY, color); - - sx += SrcZoomXHight; - sx_dec += SrcZoomXLow; - if (sx_dec >= sx_max) - { - sx++; - sx_dec -= sx_max; - } - } - - sy += SrcZoomYHight; - sy_dec += SrcZoomYLow; - if (sy_dec >= sy_max) - { - sy++; - sy_dec -= sy_max; - } - } - break; - - - - default: - DPRINT1("DIB_8BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat)); - return FALSE; - } - - return TRUE; + } + return TRUE; } BOOLEAN
15 years, 10 months
1
0
0
0
[cfinck] 39216: Merge r39215
by cfinck@svn.reactos.org
Author: cfinck Date: Fri Jan 30 11:26:41 2009 New Revision: 39216 URL:
http://svn.reactos.org/svn/reactos?rev=39216&view=rev
Log: Merge r39215 Modified: branches/ros-branch-0_3_8/rosapps/applications/downloader/downloader.xml Modified: branches/ros-branch-0_3_8/rosapps/applications/downloader/downloader.xml URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_8/rosapps/applic…
============================================================================== --- branches/ros-branch-0_3_8/rosapps/applications/downloader/downloader.xml [iso-8859-1] (original) +++ branches/ros-branch-0_3_8/rosapps/applications/downloader/downloader.xml [iso-8859-1] Fri Jan 30 11:26:41 2009 @@ -81,20 +81,20 @@ <regname>
OpenOffice.org
2.4</regname> <version>2.4.0</version> <description>THE Open Source Office Suite.</description> - <location>
http://ftp.tu-chemnitz.de/pub/openoffice-extended/stable/2.4.0/OOo_2.4.0_Wi…
</location> + <location>
http://ftp.tu-chemnitz.de/pub/openoffice/stable/3.0.1/OOo_3.0.1_Win32Intel_…
</location> </application> </category> <category name="Graphics" icon="3"> <application name="IrfanView"> <regname>IrfanView (remove only)</regname> - <version>4.10</version> + <version>4.23</version> <description>Viewer for all kinds of graphics/audio files/video files.</description> - <location>
http://gd.tuwien.ac.at/graphics/irfanview/iview410_setup.exe
</location> + <location>
http://irfanview.tuwien.ac.at/iview423_setup.exe
</location> </application> <application name="IrfanView Plugins"> - <version>4.10</version> + <version>4.22</version> <description>Additional Plugins for supporting more file types.</description> - <location>
http://irfanview.tuwien.ac.at/plugins/irfanview_plugins_410_setup.exe
</location> + <location>
http://irfanview.tuwien.ac.at/plugins/irfanview_plugins_422_setup.exe
</location> </application> <application name="TuxPaint"> <regname>Tux Paint 0.9.19</regname> @@ -254,8 +254,8 @@ <application name="uTorrent"> <regname>µTorrent</regname> <version>1.8</version> - <description>Small and fast BitTorrent Client.</description> - <location>
http://download.utorrent.com/1.8/utorrent.exe
</location> + <description>Small and fast BitTorrent Client</description> + <location>
http://download.utorrent.com/1.8.2/utorrent-1.8.2.upx.exe
</location> </application> <application name="Audio Grabber"> <regname>Audiograbber 1.83 SE</regname>
15 years, 10 months
1
0
0
0
[cfinck] 39215: Fix some deadlinks
by cfinck@svn.reactos.org
Author: cfinck Date: Fri Jan 30 11:13:37 2009 New Revision: 39215 URL:
http://svn.reactos.org/svn/reactos?rev=39215&view=rev
Log: Fix some deadlinks Modified: trunk/rosapps/applications/downloader/downloader.xml Modified: trunk/rosapps/applications/downloader/downloader.xml URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/downloader/do…
============================================================================== --- trunk/rosapps/applications/downloader/downloader.xml [iso-8859-1] (original) +++ trunk/rosapps/applications/downloader/downloader.xml [iso-8859-1] Fri Jan 30 11:13:37 2009 @@ -81,20 +81,20 @@ <regname>
OpenOffice.org
2.4</regname> <version>2.4.0</version> <description>THE Open Source Office Suite.</description> - <location>
http://ftp.tu-chemnitz.de/pub/openoffice-extended/stable/2.4.0/OOo_2.4.0_Wi…
</location> + <location>
http://ftp.tu-chemnitz.de/pub/openoffice/stable/3.0.1/OOo_3.0.1_Win32Intel_…
</location> </application> </category> <category name="Graphics" icon="3"> <application name="IrfanView"> <regname>IrfanView (remove only)</regname> - <version>4.10</version> + <version>4.23</version> <description>Viewer for all kinds of graphics/audio files/video files.</description> - <location>
http://gd.tuwien.ac.at/graphics/irfanview/iview410_setup.exe
</location> + <location>
http://irfanview.tuwien.ac.at/iview423_setup.exe
</location> </application> <application name="IrfanView Plugins"> - <version>4.10</version> + <version>4.22</version> <description>Additional Plugins for supporting more file types.</description> - <location>
http://irfanview.tuwien.ac.at/plugins/irfanview_plugins_410_setup.exe
</location> + <location>
http://irfanview.tuwien.ac.at/plugins/irfanview_plugins_422_setup.exe
</location> </application> <application name="TuxPaint"> <regname>Tux Paint 0.9.19</regname> @@ -254,8 +254,8 @@ <application name="uTorrent"> <regname>µTorrent</regname> <version>1.8</version> - <description>Small and fast BitTorrent Client.</description> - <location>
http://download.utorrent.com/1.8/utorrent.exe
</location> + <description>Small and fast BitTorrent Client</description> + <location>
http://download.utorrent.com/1.8.2/utorrent-1.8.2.upx.exe
</location> </application> <application name="Audio Grabber"> <regname>Audiograbber 1.83 SE</regname>
15 years, 10 months
1
0
0
0
[sginsberg] 39214: - Inline Guarded Mutex and Fast Mutex implementations when called from within the kernel
by sginsberg@svn.reactos.org
Author: sginsberg Date: Fri Jan 30 10:45:17 2009 New Revision: 39214 URL:
http://svn.reactos.org/svn/reactos?rev=39214&view=rev
Log: - Inline Guarded Mutex and Fast Mutex implementations when called from within the kernel Modified: trunk/reactos/ntoskrnl/ex/fmutex.c trunk/reactos/ntoskrnl/include/internal/ex.h trunk/reactos/ntoskrnl/include/internal/ke.h trunk/reactos/ntoskrnl/include/internal/ke_x.h trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h trunk/reactos/ntoskrnl/ke/gmutex.c trunk/reactos/ntoskrnl/ke/wait.c Modified: trunk/reactos/ntoskrnl/ex/fmutex.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/fmutex.c?rev=3…
============================================================================== --- trunk/reactos/ntoskrnl/ex/fmutex.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ex/fmutex.c [iso-8859-1] Fri Jan 30 10:45:17 2009 @@ -12,61 +12,14 @@ #define NDEBUG #include <debug.h> -VOID -FASTCALL -KiAcquireFastMutex( - IN PFAST_MUTEX FastMutex -); - -/* PRIVATE FUNCTIONS *********************************************************/ - -FORCEINLINE -VOID -ExiAcquireFastMutexUnsafe(IN PFAST_MUTEX FastMutex) -{ - PKTHREAD Thread = KeGetCurrentThread(); - - DPRINT("Sanity print: %d %d %p\n", - KeGetCurrentIrql(), Thread->CombinedApcDisable, Thread->Teb); - - /* Sanity check */ - ASSERT((KeGetCurrentIrql() == APC_LEVEL) || - (Thread->CombinedApcDisable != 0) || - (Thread->Teb == NULL) || - (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); - ASSERT(FastMutex->Owner != Thread); - - /* Decrease the count */ - if (InterlockedDecrement(&FastMutex->Count)) - { - /* Someone is still holding it, use slow path */ - KiAcquireFastMutex(FastMutex); - } - - /* Set the owner */ - FastMutex->Owner = Thread; -} - -FORCEINLINE -VOID -ExiReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex) -{ - ASSERT((KeGetCurrentIrql() == APC_LEVEL) || - (KeGetCurrentThread()->CombinedApcDisable != 0) || - (KeGetCurrentThread()->Teb == NULL) || - (KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); - ASSERT(FastMutex->Owner == KeGetCurrentThread()); - - /* Erase the owner */ - FastMutex->Owner = NULL; - - /* Increase the count */ - if (InterlockedIncrement(&FastMutex->Count) <= 0) - { - /* Someone was waiting for it, signal the waiter */ - KeSetEventBoostPriority(&FastMutex->Gate, NULL); - } -} +/* Undefine some macros we implement here */ +#undef ExEnterCriticalRegionAndAcquireFastMutexUnsafe +#undef ExReleaseFastMutexUnsafeAndLeaveCriticalRegion +#undef ExAcquireFastMutex +#undef ExReleaseFastMutex +#undef ExAcquireFastMutexUnsafe +#undef ExReleaseFastMutexUnsafe +#undef ExTryToAcquireFastMutex /* PUBLIC FUNCTIONS **********************************************************/ @@ -77,11 +30,8 @@ FASTCALL ExEnterCriticalRegionAndAcquireFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex) { - /* Enter the Critical Region */ - KeEnterCriticalRegion(); - - /* Acquire the mutex unsafely */ - ExiAcquireFastMutexUnsafe(FastMutex); + /* Call the inline */ + _ExEnterCriticalRegionAndAcquireFastMutexUnsafe(FastMutex); } /* @@ -91,11 +41,8 @@ FASTCALL ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(IN OUT PFAST_MUTEX FastMutex) { - /* Release the mutex unsafely */ - ExiReleaseFastMutexUnsafe(FastMutex); - - /* Leave the critical region */ - KeLeaveCriticalRegion(); + /* Call the inline */ + _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(FastMutex); } /* @@ -105,22 +52,8 @@ FASTCALL ExAcquireFastMutex(IN OUT PFAST_MUTEX FastMutex) { - KIRQL OldIrql; - ASSERT(KeGetCurrentIrql() <= APC_LEVEL); - - /* Raise IRQL to APC */ - KeRaiseIrql(APC_LEVEL, &OldIrql); - - /* Decrease the count */ - if (InterlockedDecrement(&FastMutex->Count) != 0) - { - /* Someone is still holding it, use slow path */ - KiAcquireFastMutex(FastMutex); - } - - /* Set the owner and IRQL */ - FastMutex->Owner = KeGetCurrentThread(); - FastMutex->OldIrql = OldIrql; + /* Call the inline */ + _ExAcquireFastMutex(FastMutex); } /* @@ -130,22 +63,8 @@ FASTCALL ExReleaseFastMutex(IN OUT PFAST_MUTEX FastMutex) { - KIRQL OldIrql; - ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL); - - /* Erase the owner */ - FastMutex->Owner = NULL; - OldIrql = (KIRQL)FastMutex->OldIrql; - - /* Increase the count */ - if (InterlockedIncrement(&FastMutex->Count) <= 0) - { - /* Someone was waiting for it, signal the waiter */ - KeSetEventBoostPriority(&FastMutex->Gate, IO_NO_INCREMENT); - } - - /* Lower IRQL back */ - KeLowerIrql(OldIrql); + /* Call the inline */ + _ExReleaseFastMutex(FastMutex); } /* @@ -156,7 +75,7 @@ ExAcquireFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex) { /* Acquire the mutex unsafely */ - ExiAcquireFastMutexUnsafe(FastMutex); + _ExAcquireFastMutexUnsafe(FastMutex); } /* @@ -167,7 +86,7 @@ ExReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex) { /* Release the mutex unsafely */ - ExiReleaseFastMutexUnsafe(FastMutex); + _ExReleaseFastMutexUnsafe(FastMutex); } /* @@ -177,26 +96,8 @@ FASTCALL ExTryToAcquireFastMutex(IN OUT PFAST_MUTEX FastMutex) { - KIRQL OldIrql; - ASSERT(KeGetCurrentIrql() <= APC_LEVEL); - - /* Raise to APC_LEVEL */ - KeRaiseIrql(APC_LEVEL, &OldIrql); - - /* Check if we can quickly acquire it */ - if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1) - { - /* We have, set us as owners */ - FastMutex->Owner = KeGetCurrentThread(); - FastMutex->OldIrql = OldIrql; - return TRUE; - } - else - { - /* Acquire attempt failed */ - KeLowerIrql(OldIrql); - return FALSE; - } + /* Call the inline */ + return _ExTryToAcquireFastMutex(FastMutex); } /* EOF */ Modified: trunk/reactos/ntoskrnl/include/internal/ex.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ex.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/ex.h [iso-8859-1] Fri Jan 30 10:45:17 2009 @@ -994,6 +994,146 @@ } } +/* FAST MUTEX INLINES *********************************************************/ + +FORCEINLINE +VOID +_ExAcquireFastMutexUnsafe(IN PFAST_MUTEX FastMutex) +{ + PKTHREAD Thread = KeGetCurrentThread(); + + /* Sanity check */ + ASSERT((KeGetCurrentIrql() == APC_LEVEL) || + (Thread->CombinedApcDisable != 0) || + (Thread->Teb == NULL) || + (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); + ASSERT(FastMutex->Owner != Thread); + + /* Decrease the count */ + if (InterlockedDecrement(&FastMutex->Count)) + { + /* Someone is still holding it, use slow path */ + KiAcquireFastMutex(FastMutex); + } + + /* Set the owner */ + FastMutex->Owner = Thread; +} + +FORCEINLINE +VOID +_ExReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex) +{ + ASSERT((KeGetCurrentIrql() == APC_LEVEL) || + (KeGetCurrentThread()->CombinedApcDisable != 0) || + (KeGetCurrentThread()->Teb == NULL) || + (KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); + ASSERT(FastMutex->Owner == KeGetCurrentThread()); + + /* Erase the owner */ + FastMutex->Owner = NULL; + + /* Increase the count */ + if (InterlockedIncrement(&FastMutex->Count) <= 0) + { + /* Someone was waiting for it, signal the waiter */ + KeSetEventBoostPriority(&FastMutex->Gate, NULL); + } +} + +FORCEINLINE +VOID +_ExAcquireFastMutex(IN PFAST_MUTEX FastMutex) +{ + KIRQL OldIrql; + ASSERT(KeGetCurrentIrql() <= APC_LEVEL); + + /* Raise IRQL to APC */ + KeRaiseIrql(APC_LEVEL, &OldIrql); + + /* Decrease the count */ + if (InterlockedDecrement(&FastMutex->Count)) + { + /* Someone is still holding it, use slow path */ + KiAcquireFastMutex(FastMutex); + } + + /* Set the owner and IRQL */ + FastMutex->Owner = KeGetCurrentThread(); + FastMutex->OldIrql = OldIrql; +} + +FORCEINLINE +VOID +_ExReleaseFastMutex(IN OUT PFAST_MUTEX FastMutex) +{ + KIRQL OldIrql; + ASSERT(KeGetCurrentIrql() == APC_LEVEL); + + /* Erase the owner */ + FastMutex->Owner = NULL; + OldIrql = (KIRQL)FastMutex->OldIrql; + + /* Increase the count */ + if (InterlockedIncrement(&FastMutex->Count) <= 0) + { + /* Someone was waiting for it, signal the waiter */ + KeSetEventBoostPriority(&FastMutex->Gate, NULL); + } + + /* Lower IRQL back */ + KeLowerIrql(OldIrql); +} + +FORCEINLINE +BOOLEAN +_ExTryToAcquireFastMutex(IN OUT PFAST_MUTEX FastMutex) +{ + KIRQL OldIrql; + ASSERT(KeGetCurrentIrql() <= APC_LEVEL); + + /* Raise to APC_LEVEL */ + KeRaiseIrql(APC_LEVEL, &OldIrql); + + /* Check if we can quickly acquire it */ + if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1) + { + /* We have, set us as owners */ + FastMutex->Owner = KeGetCurrentThread(); + FastMutex->OldIrql = OldIrql; + return TRUE; + } + else + { + /* Acquire attempt failed */ + KeLowerIrql(OldIrql); + YieldProcessor(); + return FALSE; + } +} + +FORCEINLINE +VOID +_ExEnterCriticalRegionAndAcquireFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex) +{ + /* Enter the Critical Region */ + KeEnterCriticalRegion(); + + /* Acquire the mutex unsafely */ + _ExAcquireFastMutexUnsafe(FastMutex); +} + +FORCEINLINE +VOID +_ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(IN OUT PFAST_MUTEX FastMutex) +{ + /* Release the mutex unsafely */ + _ExReleaseFastMutexUnsafe(FastMutex); + + /* Leave the critical region */ + KeLeaveCriticalRegion(); +} + /* OTHER FUNCTIONS **********************************************************/ BOOLEAN Modified: trunk/reactos/ntoskrnl/include/internal/ke.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] Fri Jan 30 10:45:17 2009 @@ -312,7 +312,15 @@ VOID FASTCALL -KiAcquireGuardedMutexContented(PKGUARDED_MUTEX GuardedMutex); +KiAcquireGuardedMutex( + IN OUT PKGUARDED_MUTEX GuardedMutex +); + +VOID +FASTCALL +KiAcquireFastMutex( + IN PFAST_MUTEX FastMutex +); /* gate.c **********************************************************************/ Modified: trunk/reactos/ntoskrnl/include/internal/ke_x.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] Fri Jan 30 10:45:17 2009 @@ -169,10 +169,6 @@ } \ } \ } - -// -// TODO: Guarded Mutex Routines -// // // Enters a Critical Region @@ -1710,3 +1706,178 @@ /* Return the new priority */ return Priority; } + +// +// Guarded Mutex Routines +// +FORCEINLINE +VOID +_KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex) +{ + /* Setup the Initial Data */ + GuardedMutex->Count = GM_LOCK_BIT; + GuardedMutex->Owner = NULL; + GuardedMutex->Contention = 0; + + /* Initialize the Wait Gate */ + KeInitializeGate(&GuardedMutex->Gate); +} + +FORCEINLINE +VOID +_KeAcquireGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex) +{ + PKTHREAD Thread = KeGetCurrentThread(); + + /* Sanity checks */ + ASSERT((KeGetCurrentIrql() == APC_LEVEL) || + (Thread->SpecialApcDisable < 0) || + (Thread->Teb == NULL) || + (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); + ASSERT(GuardedMutex->Owner != Thread); + + /* Remove the lock */ + if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V)) + { + /* The Guarded Mutex was already locked, enter contented case */ + KiAcquireGuardedMutex(GuardedMutex); + } + + /* Set the Owner */ + GuardedMutex->Owner = Thread; +} + +FORCEINLINE +VOID +_KeReleaseGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex) +{ + LONG OldValue, NewValue; + + /* Sanity checks */ + ASSERT((KeGetCurrentIrql() == APC_LEVEL) || + (KeGetCurrentThread()->SpecialApcDisable < 0) || + (KeGetCurrentThread()->Teb == NULL) || + (KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); + ASSERT(GuardedMutex->Owner == KeGetCurrentThread()); + + /* Destroy the Owner */ + GuardedMutex->Owner = NULL; + + /* Add the Lock Bit */ + OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT); + ASSERT((OldValue & GM_LOCK_BIT) == 0); + + /* Check if it was already locked, but not woken */ + if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN)) + { + /* Update the Oldvalue to what it should be now */ + OldValue += GM_LOCK_BIT; + + /* The mutex will be woken, minus one waiter */ + NewValue = OldValue + GM_LOCK_WAITER_WOKEN - + GM_LOCK_WAITER_INC; + + /* Remove the Woken bit */ + if (InterlockedCompareExchange(&GuardedMutex->Count, + NewValue, + OldValue) == OldValue) + { + /* Signal the Gate */ + KeSignalGateBoostPriority(&GuardedMutex->Gate); + } + } +} + +FORCEINLINE +VOID +_KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex) +{ + PKTHREAD Thread = KeGetCurrentThread(); + + /* Sanity checks */ + ASSERT(KeGetCurrentIrql() <= APC_LEVEL); + ASSERT(GuardedMutex->Owner != Thread); + + /* Disable Special APCs */ + KeEnterGuardedRegion(); + + /* Remove the lock */ + if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V)) + { + /* The Guarded Mutex was already locked, enter contented case */ + KiAcquireGuardedMutex(GuardedMutex); + } + + /* Set the Owner and Special APC Disable state */ + GuardedMutex->Owner = Thread; + GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable; +} + +FORCEINLINE +VOID +_KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) +{ + LONG OldValue, NewValue; + + /* Sanity checks */ + ASSERT(KeGetCurrentIrql() <= APC_LEVEL); + ASSERT(GuardedMutex->Owner == KeGetCurrentThread()); + ASSERT(KeGetCurrentThread()->SpecialApcDisable == + GuardedMutex->SpecialApcDisable); + + /* Destroy the Owner */ + GuardedMutex->Owner = NULL; + + /* Add the Lock Bit */ + OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT); + ASSERT((OldValue & GM_LOCK_BIT) == 0); + + /* Check if it was already locked, but not woken */ + if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN)) + { + /* Update the Oldvalue to what it should be now */ + OldValue += GM_LOCK_BIT; + + /* The mutex will be woken, minus one waiter */ + NewValue = OldValue + GM_LOCK_WAITER_WOKEN - + GM_LOCK_WAITER_INC; + + /* Remove the Woken bit */ + if (InterlockedCompareExchange(&GuardedMutex->Count, + NewValue, + OldValue) == OldValue) + { + /* Signal the Gate */ + KeSignalGateBoostPriority(&GuardedMutex->Gate); + } + } + + /* Re-enable APCs */ + KeLeaveGuardedRegion(); +} + +FORCEINLINE +BOOLEAN +_KeTryToAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) +{ + PKTHREAD Thread = KeGetCurrentThread(); + + /* Block APCs */ + KeEnterGuardedRegion(); + + /* Remove the lock */ + if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V)) + { + /* Re-enable APCs */ + KeLeaveGuardedRegion(); + YieldProcessor(); + + /* Return failure */ + return FALSE; + } + + /* Set the Owner and APC State */ + GuardedMutex->Owner = Thread; + GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable; + return TRUE; +} Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h [iso-8859-1] Fri Jan 30 10:45:17 2009 @@ -41,6 +41,24 @@ #define InterlockedExchangeAdd _InterlockedExchangeAdd #define InterlockedOr _InterlockedOr #define InterlockedAnd _InterlockedAnd + +// +// Use inlined versions of fast/guarded mutex routines +// +#define ExEnterCriticalRegionAndAcquireFastMutexUnsafe _ExEnterCriticalRegionAndAcquireFastMutexUnsafe +#define ExReleaseFastMutexUnsafeAndLeaveCriticalRegion _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion +#define ExAcquireFastMutex _ExAcquireFastMutex +#define ExReleaseFastMutex _ExReleaseFastMutex +#define ExAcquireFastMutexUnsafe _ExAcquireFastMutexUnsafe +#define ExReleaseFastMutexUnsafe _ExReleaseFastMutexUnsafe +#define ExTryToAcquireFastMutex _ExTryToAcquireFastMutex + +#define KeInitializeGuardedMutex _KeInitializeGuardedMutex +#define KeAcquireGuardedMutex _KeAcquireGuardedMutex +#define KeReleaseGuardedMutex _KeReleaseGuardedMutex +#define KeAcquireGuardedMutexUnsafe _KeAcquireGuardedMutexUnsafe +#define KeReleaseGuardedMutexUnsafe _KeReleaseGuardedMutexUnsafe +#define KeTryToAcquireGuardedMutex _KeTryToAcquireGuardedMutex #include "ke.h" #include "ob.h" Modified: trunk/reactos/ntoskrnl/ke/gmutex.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/gmutex.c?rev=3…
============================================================================== --- trunk/reactos/ntoskrnl/ke/gmutex.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/gmutex.c [iso-8859-1] Fri Jan 30 10:45:17 2009 @@ -13,128 +13,13 @@ #define NDEBUG #include <debug.h> -/* PRIVATE FUNCTIONS *********************************************************/ - -VOID -FASTCALL -KiAcquireGuardedMutexContented(IN OUT PKGUARDED_MUTEX GuardedMutex) -{ - ULONG BitsToRemove, BitsToAdd; - LONG OldValue, NewValue; - - /* Increase the contention count */ - GuardedMutex->Contention++; - - /* Start by unlocking the Guarded Mutex */ - BitsToRemove = GM_LOCK_BIT; - BitsToAdd = GM_LOCK_WAITER_INC; - - /* Start change loop */ - for (;;) - { - /* Loop sanity checks */ - ASSERT((BitsToRemove == GM_LOCK_BIT) || - (BitsToRemove == (GM_LOCK_BIT | GM_LOCK_WAITER_WOKEN))); - ASSERT((BitsToAdd == GM_LOCK_WAITER_INC) || - (BitsToAdd == GM_LOCK_WAITER_WOKEN)); - - /* Get the Count Bits */ - OldValue = GuardedMutex->Count; - - /* Start internal bit change loop */ - for (;;) - { - /* Check if the Guarded Mutex is locked */ - if (OldValue & GM_LOCK_BIT) - { - /* Sanity check */ - ASSERT((BitsToRemove == GM_LOCK_BIT) || - ((OldValue & GM_LOCK_WAITER_WOKEN) != 0)); - - /* Unlock it by removing the Lock Bit */ - NewValue = OldValue ^ BitsToRemove; - NewValue = InterlockedCompareExchange(&GuardedMutex->Count, - NewValue, - OldValue); - if (NewValue == OldValue) return; - } - else - { - /* The Guarded Mutex isn't locked, so simply set the bits */ - NewValue = OldValue + BitsToAdd; - NewValue = InterlockedCompareExchange(&GuardedMutex->Count, - NewValue, - OldValue); - if (NewValue == OldValue) break; - } - - /* Old value changed, loop again */ - OldValue = NewValue; - } - - /* Now we have to wait for it */ - KeWaitForGate(&GuardedMutex->Gate, WrGuardedMutex, KernelMode); - ASSERT((GuardedMutex->Count & GM_LOCK_WAITER_WOKEN) != 0); - - /* Ok, the wait is done, so set the new bits */ - BitsToRemove = GM_LOCK_BIT | GM_LOCK_WAITER_WOKEN; - BitsToAdd = GM_LOCK_WAITER_WOKEN; - - /* We depend on these bits being just right */ - C_ASSERT((GM_LOCK_WAITER_WOKEN * 2) == GM_LOCK_WAITER_INC); - } -} - -FORCEINLINE -VOID -FASTCALL -KiAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) -{ - BOOLEAN OldBit; - - /* Remove the lock */ - OldBit = InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V); - if (!OldBit) - { - /* The Guarded Mutex was already locked, enter contented case */ - KiAcquireGuardedMutexContented(GuardedMutex); - } -} - -FORCEINLINE -VOID -FASTCALL -KiReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) -{ - LONG OldValue, NewValue; - - /* Destroy the Owner */ - GuardedMutex->Owner = NULL; - - /* Add the Lock Bit */ - OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT); - ASSERT((OldValue & GM_LOCK_BIT) == 0); - - /* Check if it was already locked, but not woken */ - if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN)) - { - /* Update the Oldvalue to what it should be now */ - OldValue += GM_LOCK_BIT; - - /* The mutex will be woken, minus one waiter */ - NewValue = OldValue + GM_LOCK_WAITER_WOKEN - - GM_LOCK_WAITER_INC; - - /* Remove the Woken bit */ - if (InterlockedCompareExchange(&GuardedMutex->Count, - NewValue, - OldValue) == OldValue) - { - /* Signal the Gate */ - KeSignalGateBoostPriority(&GuardedMutex->Gate); - } - } -} +/* Undefine some macros we implement here */ +#undef KeInitializeGuardedMutex +#undef KeAcquireGuardedMutex +#undef KeReleaseGuardedMutex +#undef KeAcquireGuardedMutexUnsafe +#undef KeReleaseGuardedMutexUnsafe +#undef KeTryToAcquireGuardedMutex /* PUBLIC FUNCTIONS **********************************************************/ @@ -145,13 +30,30 @@ FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex) { - /* Setup the Initial Data */ - GuardedMutex->Count = GM_LOCK_BIT; - GuardedMutex->Owner = NULL; - GuardedMutex->Contention = 0; + /* Call the inline */ + _KeInitializeGuardedMutex(GuardedMutex); +} - /* Initialize the Wait Gate */ - KeInitializeGate(&GuardedMutex->Gate); +/* + * @implemented + */ +VOID +FASTCALL +KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex) +{ + /* Call the inline */ + _KeAcquireGuardedMutex(GuardedMutex); +} + +/* + * @implemented + */ +VOID +FASTCALL +KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) +{ + /* Call the inline */ + _KeReleaseGuardedMutex(GuardedMutex); } /* @@ -161,20 +63,8 @@ FASTCALL KeAcquireGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex) { - PKTHREAD Thread = KeGetCurrentThread(); - - /* Sanity checks */ - ASSERT((KeGetCurrentIrql() == APC_LEVEL) || - (Thread->SpecialApcDisable < 0) || - (Thread->Teb == NULL) || - (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); - ASSERT(GuardedMutex->Owner != Thread); - - /* Do the actual acquire */ - KiAcquireGuardedMutex(GuardedMutex); - - /* Set the Owner */ - GuardedMutex->Owner = Thread; + /* Call the inline */ + _KeAcquireGuardedMutexUnsafe(GuardedMutex); } /* @@ -184,59 +74,8 @@ FASTCALL KeReleaseGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex) { - /* Sanity checks */ - ASSERT((KeGetCurrentIrql() == APC_LEVEL) || - (KeGetCurrentThread()->SpecialApcDisable < 0) || - (KeGetCurrentThread()->Teb == NULL) || - (KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); - ASSERT(GuardedMutex->Owner == KeGetCurrentThread()); - - /* Release the mutex */ - KiReleaseGuardedMutex(GuardedMutex); -} - -/* - * @implemented - */ -VOID -FASTCALL -KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex) -{ - PKTHREAD Thread = KeGetCurrentThread(); - - /* Sanity checks */ - ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL); - ASSERT(GuardedMutex->Owner != Thread); - - /* Disable Special APCs */ - KeEnterGuardedRegion(); - - /* Do the actual acquire */ - KiAcquireGuardedMutex(GuardedMutex); - - /* Set the Owner and Special APC Disable state */ - GuardedMutex->Owner = Thread; - GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable; -} - -/* - * @implemented - */ -VOID -FASTCALL -KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) -{ - /* Sanity checks */ - ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL); - ASSERT(GuardedMutex->Owner == KeGetCurrentThread()); - ASSERT(GuardedMutex->SpecialApcDisable == - KeGetCurrentThread()->SpecialApcDisable); - - /* Release the mutex */ - KiReleaseGuardedMutex(GuardedMutex); - - /* Re-enable APCs */ - KeLeaveGuardedRegion(); + /* Call the inline */ + _KeReleaseGuardedMutexUnsafe(GuardedMutex); } /* @@ -246,28 +85,8 @@ FASTCALL KeTryToAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) { - PKTHREAD Thread = KeGetCurrentThread(); - BOOLEAN OldBit; - - /* Block APCs */ - KeEnterGuardedRegion(); - - /* Remove the lock */ - OldBit = InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V); - if (!OldBit) - { - /* Re-enable APCs */ - KeLeaveGuardedRegion(); - YieldProcessor(); - - /* Return failure */ - return FALSE; - } - - /* Set the Owner and APC State */ - GuardedMutex->Owner = Thread; - GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable; - return TRUE; + /* Call the inline */ + return _KeTryToAcquireGuardedMutex(GuardedMutex); } /** Modified: trunk/reactos/ntoskrnl/ke/wait.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/wait.c?rev=392…
============================================================================== --- trunk/reactos/ntoskrnl/ke/wait.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/wait.c [iso-8859-1] Fri Jan 30 10:45:17 2009 @@ -115,6 +115,76 @@ KernelMode, FALSE, NULL); +} + +VOID +FASTCALL +KiAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) +{ + ULONG BitsToRemove, BitsToAdd; + LONG OldValue, NewValue; + + /* Increase the contention count */ + GuardedMutex->Contention++; + + /* Start by unlocking the Guarded Mutex */ + BitsToRemove = GM_LOCK_BIT; + BitsToAdd = GM_LOCK_WAITER_INC; + + /* Start change loop */ + for (;;) + { + /* Loop sanity checks */ + ASSERT((BitsToRemove == GM_LOCK_BIT) || + (BitsToRemove == (GM_LOCK_BIT | GM_LOCK_WAITER_WOKEN))); + ASSERT((BitsToAdd == GM_LOCK_WAITER_INC) || + (BitsToAdd == GM_LOCK_WAITER_WOKEN)); + + /* Get the Count Bits */ + OldValue = GuardedMutex->Count; + + /* Start internal bit change loop */ + for (;;) + { + /* Check if the Guarded Mutex is locked */ + if (OldValue & GM_LOCK_BIT) + { + /* Sanity check */ + ASSERT((BitsToRemove == GM_LOCK_BIT) || + ((OldValue & GM_LOCK_WAITER_WOKEN) != 0)); + + /* Unlock it by removing the Lock Bit */ + NewValue = OldValue ^ BitsToRemove; + NewValue = InterlockedCompareExchange(&GuardedMutex->Count, + NewValue, + OldValue); + if (NewValue == OldValue) return; + } + else + { + /* The Guarded Mutex isn't locked, so simply set the bits */ + NewValue = OldValue + BitsToAdd; + NewValue = InterlockedCompareExchange(&GuardedMutex->Count, + NewValue, + OldValue); + if (NewValue == OldValue) break; + } + + /* Old value changed, loop again */ + OldValue = NewValue; + } + + /* Now we have to wait for it */ + KeWaitForGate(&GuardedMutex->Gate, WrGuardedMutex, KernelMode); + ASSERT((GuardedMutex->Count & GM_LOCK_WAITER_WOKEN) != 0); + + /* Ok, the wait is done, so set the new bits */ + BitsToRemove = GM_LOCK_BIT | GM_LOCK_WAITER_WOKEN; + BitsToAdd = GM_LOCK_WAITER_WOKEN; + + /* We depend on these bits being just right */ + C_ASSERT((GM_LOCK_WAITER_WOKEN * 2) == GM_LOCK_WAITER_INC); + } } //
15 years, 10 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
...
76
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Results per page:
10
25
50
100
200