diff options
| author | alexke-dev <[email protected]> | 2023-08-10 16:28:02 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-10 16:28:02 -0700 |
| commit | cbbd53eda55fbdf65f22b5f57c7dbc4b1ea594fd (patch) | |
| tree | 50df874afbb353d7d3864b559c6b7641f1208924 /print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.cpp | |
| parent | 6ea518dd65b6c2c3b298bb8e7ed5e9124b8a4981 (diff) | |
Remove Print Driver Samples (#1017)
* Remove print driver samples. Add README.md to redirect consumers to Print Support App (PSA) development guide.
* Remove en-us from URL.
Diffstat (limited to 'print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.cpp')
| -rw-r--r-- | print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.cpp | 187 |
1 files changed, 0 insertions, 187 deletions
diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.cpp deleted file mode 100644 index 15234361..00000000 --- a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -// PARTICULAR PURPOSE. -// -// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. -// -// FILE: Devmode.cpp -// -// -// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. -// - - -#include "precomp.h" -#include "oemui.h" -#include "debug.h" -#include "devmode.h" - - -// This indicates to Prefast that this is a usermode driver file. -_Analysis_mode_(_Analysis_code_type_user_driver_); - -// -//Performs operation on UI Plugins Private DevMode Members. -//Called via IOemUI::DevMode -// - -HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam) -{ - POEMDEV pOEMDevIn; - POEMDEV pOEMDevOut; - - - // Verify parameters. - if( (NULL == pOemDMParam) - || - ( (OEMDM_SIZE != dwMode) - && - (OEMDM_DEFAULT != dwMode) - && - (OEMDM_CONVERT != dwMode) - && - (OEMDM_MERGE != dwMode) - ) - ) - { - ERR(DLLTEXT("DevMode() ERROR_INVALID_PARAMETER.\r\n")); - SetLastError(ERROR_INVALID_PARAMETER); - return E_FAIL; - } - - // Cast generic (i.e. PVOID) to OEM private devomode pointer type. - pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; - pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; - - switch(dwMode) - { - // - //The Method should return the size of the memory allocation needed to store the UI plugin Private DEVMODE. - // - case OEMDM_SIZE: - pOemDMParam->cbBufSize = sizeof(OEMDEV); - break; - - // - //Should fill the Private DEVMODE with the default values. - // - case OEMDM_DEFAULT: - // - //OEM_DMEXTRAHEADER Members - // - pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); - pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; - pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; - - // - //Private members - // - pOEMDevOut->dwDriverData = 0; - pOEMDevOut->dwAdvancedData = 0; - - VERBOSE(DLLTEXT("pOEMDevOut after setting default values:\r\n")); - break; - - // - //The method should convert private DEVMODE members to the current version, if necessary. - // - case OEMDM_CONVERT: - ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); - break; - - // - //The method should validate the information contained in private DEVMODE members and merge validated values into a private DEVMODE structure containing default values - // - case OEMDM_MERGE: - ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); - MakeOEMDevmodeValid(pOEMDevOut); - break; - } - - return S_OK; -} - - -BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut) -{ - if( (NULL == pOEMDevIn) - || - (NULL == pOEMDevOut) - ) - { - ERR(DLLTEXT("ConvertOEMDevmode() invalid parameters.\r\n")); - return FALSE; - } - - // Check OEM Signature, if it doesn't match ours, - // then just assume DMIn is bad and use defaults. - if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) - { - VERBOSE(DLLTEXT("Converting private OEM Devmode.\r\n")); - VERBOSE(DLLTEXT("pOEMDevIn:\r\n")); - - // Set the devmode defaults so that anything the isn't copied over will - // be set to the default value. - pOEMDevOut->dwDriverData = 0; - pOEMDevOut->dwAdvancedData = 0; - - // Copy the old structure in to the new using which ever size is the smaller. - // Devmode maybe from newer Devmode (not likely since there is only one), or - // Devmode maybe a newer Devmode, in which case it maybe larger, - // but the first part of the structure should be the same. - - // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; - // the fields that are in the DEVMODE never change only new fields get added to the end. - - memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); - - // Re-fill in the size and version fields to indicated - // that the DEVMODE is the current private DEVMODE version. - pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); - pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; - } - else - { - WARNING(DLLTEXT("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n")); - - // Don't know what the input DEVMODE is, so just use defaults. - pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); - pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; - pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; - pOEMDevOut->dwDriverData = 0; - pOEMDevOut->dwAdvancedData = 0; - } - - return TRUE; -} - - -BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode) -{ - if(NULL == pOEMDevmode) - { - return FALSE; - } - - // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. - - // Make sure that dmOEMExtra indicates the current OEMDEV structure. - pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); - pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; - pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; - - // Set driver data, if not valid. - if(pOEMDevmode->dwDriverData > 100) - { - pOEMDevmode->dwDriverData = 0; - } - - // Set Advanced driver data, if not valid. - if(pOEMDevmode->dwAdvancedData > 100) - { - pOEMDevmode->dwAdvancedData = 0; - } - - return TRUE; -} |
