Exemplo n.º 1
0
inline HRESULT LoadCabinetDll()
{
    HRESULT hr = S_OK;
    if (!vhCabinetDll)
    {
        hr = LoadSystemLibrary(L"cabinet.dll", &vhCabinetDll);
        ExitOnFailure(hr, "failed to load cabinet.dll");

        // retrieve all address functions
        vpfnFDICreate = reinterpret_cast<PFNFDICREATE>(::GetProcAddress(vhCabinetDll, "FDICreate"));
        ExitOnNullWithLastError(vpfnFDICreate, hr, "failed to import FDICreate from CABINET.DLL");
        vpfnFDICopy = reinterpret_cast<PFNFDICOPY>(::GetProcAddress(vhCabinetDll, "FDICopy"));
        ExitOnNullWithLastError(vpfnFDICopy, hr, "failed to import FDICopy from CABINET.DLL");
        vpfnFDIIsCabinet = reinterpret_cast<PFNFDIISCABINET>(::GetProcAddress(vhCabinetDll, "FDIIsCabinet"));
        ExitOnNullWithLastError(vpfnFDIIsCabinet, hr, "failed to import FDIIsCabinetfrom CABINET.DLL");
        vpfnFDIDestroy = reinterpret_cast<PFNFDIDESTROY>(::GetProcAddress(vhCabinetDll, "FDIDestroy"));
        ExitOnNullWithLastError(vpfnFDIDestroy, hr, "failed to import FDIDestroyfrom CABINET.DLL");

        vhfdi = vpfnFDICreate(CabExtractAlloc, CabExtractFree, CabExtractOpen, CabExtractRead, CabExtractWrite, CabExtractClose, CabExtractSeek, cpuUNKNOWN, &verf);
        ExitOnNull(vhfdi, hr, E_FAIL, "failed to initialize cabinet.dll");
    }

LExit:
    if (FAILED(hr) && vhCabinetDll)
    {
        ::FreeLibrary(vhCabinetDll);
        vhCabinetDll = NULL;
    }

    return hr;
}
Exemplo n.º 2
0
static HRESULT RmuInitialize()
{
    HRESULT hr = S_OK;
    HMODULE hModule = NULL;

    LONG iRef = ::InterlockedIncrement(&vcRmuInitialized);
    if (1 == iRef && !vhModule)
    {
        hr = LoadSystemLibrary(L"rstrtmgr.dll", &hModule);
        ExitOnFailure(hr, "Failed to load the rstrtmgr.dll module.");

        vpfnRmJoinSession = reinterpret_cast<PFNRMJOINSESSION>(::GetProcAddress(hModule, "RmJoinSession"));
        ExitOnNullWithLastError(vpfnRmJoinSession, hr, "Failed to get the RmJoinSession procedure from rstrtmgr.dll.");

        vpfnRmRegisterResources = reinterpret_cast<PFNRMREGISTERRESOURCES>(::GetProcAddress(hModule, "RmRegisterResources"));
        ExitOnNullWithLastError(vpfnRmRegisterResources, hr, "Failed to get the RmRegisterResources procedure from rstrtmgr.dll.");

        vpfnRmEndSession = reinterpret_cast<PFNRMENDSESSION>(::GetProcAddress(hModule, "RmEndSession"));
        ExitOnNullWithLastError(vpfnRmEndSession, hr, "Failed to get the RmEndSession procedure from rstrtmgr.dll.");

        vhModule = hModule;
    }

LExit:
    return hr;
}
Exemplo n.º 3
0
/********************************************************************
DetectWDDMDriver

 Set a property if the driver on the machine is a WDDM driver. One
 reliable way to detect the presence of a WDDM driver is to try and
 use the Direct3DCreate9Ex() function. This method attempts that
 then sets the property appropriately.
********************************************************************/
static HRESULT DetectWDDMDriver()
{
    HRESULT hr = S_OK;
    HMODULE hModule = NULL;

    // Manually load the d3d9.dll library. If the library couldn't be loaded then we obviously won't be able
    // to try calling the function so just return.
    hr = LoadSystemLibrary(L"d3d9.dll", &hModule);
    if (E_MODNOTFOUND == hr)
    {
        TraceError(hr, "Unable to load DirectX APIs, skipping WDDM driver check.");
        ExitFunction1(hr = S_OK);
    }
    ExitOnFailure(hr, "Failed to the load the existing DirectX APIs.");

    // Obtain the address of the Direct3DCreate9Ex function. If this fails we know it isn't a WDDM
    // driver so just exit.
    const void* Direct3DCreate9ExPtr = ::GetProcAddress(hModule, "Direct3DCreate9Ex");
    ExitOnNull(Direct3DCreate9ExPtr, hr, S_OK, "Unable to load Direct3DCreateEx function, so the driver is not a WDDM driver.");

    // At this point we know it's a WDDM driver so set the property.
    hr = WcaSetIntProperty(L"WIX_WDDM_DRIVER_PRESENT", 1);
    ExitOnFailure(hr, "Failed write property");

LExit:
    if (NULL != hModule)
    {
        FreeLibrary(hModule);
    }

    return hr;
}
Exemplo n.º 4
0
DAPI_(HRESULT) SrpInitialize(
    __in BOOL fInitializeComSecurity
    )
{
    HRESULT hr = S_OK;

    hr = LoadSystemLibrary(L"srclient.dll", &vhSrClientDll);
    if (FAILED(hr))
    {
        ExitFunction1(hr = E_NOTIMPL);
    }

    vpfnSRSetRestorePointW = reinterpret_cast<PFN_SETRESTOREPTW>(::GetProcAddress(vhSrClientDll, "SRSetRestorePointW"));
    ExitOnNullWithLastError(vpfnSRSetRestorePointW, hr, "Failed to find set restore point proc address.");

    // If allowed, initialize COM security to enable NetworkService,
    // LocalService and System to make callbacks to the process
    // calling System Restore. This is required for any process
    // that calls SRSetRestorePoint.
    if (fInitializeComSecurity)
    {
        hr = InitializeComSecurity();
        ExitOnFailure(hr, "Failed to initialize security for COM to talk to system restore.");
    }

LExit:
    if (FAILED(hr) && vhSrClientDll)
    {
        SrpUninitialize();
    }

    return hr;
}
Exemplo n.º 5
0
extern "C" HRESULT DAPI ShelGetKnownFolder(
    __out_z LPWSTR* psczFolderPath,
    __in REFKNOWNFOLDERID rfidFolder
    )
{
    HRESULT hr = S_OK;
    HMODULE hShell32Dll = NULL;
    PFN_SHGetKnownFolderPath pfn = NULL;
    LPWSTR pwzPath = NULL;

    hr = LoadSystemLibrary(L"shell32.dll", &hShell32Dll);
    if (E_MODNOTFOUND == hr)
    {
        TraceError(hr, "Failed to load shell32.dll");
        ExitFunction1(hr = E_NOTIMPL);
    }
    ExitOnFailure(hr, "Failed to load shell32.dll.");

    pfn = reinterpret_cast<PFN_SHGetKnownFolderPath>(::GetProcAddress(hShell32Dll, "SHGetKnownFolderPath"));
    ExitOnNull(pfn, hr, E_NOTIMPL, "Failed to find SHGetKnownFolderPath entry point.");

    hr = pfn(rfidFolder, KF_FLAG_CREATE, NULL, &pwzPath);
    ExitOnFailure(hr, "Failed to get known folder path.");

    hr = StrAllocString(psczFolderPath, pwzPath, 0);
    ExitOnFailure1(hr, "Failed to copy shell folder path: %ls", pwzPath);

    hr = PathBackslashTerminate(psczFolderPath);
    ExitOnFailure1(hr, "Failed to backslash terminate shell folder path: %ls", *psczFolderPath);

LExit:
    if (pwzPath)
    {
        ::CoTaskMemFree(pwzPath);
    }

    if (hShell32Dll)
    {
        ::FreeLibrary(hShell32Dll);
    }

    return hr;
}
Exemplo n.º 6
0
/********************************************************************
 RegInitialize - initializes regutil

*********************************************************************/
extern "C" HRESULT DAPI RegInitialize(
    )
{
    HRESULT hr = S_OK;

    hr = LoadSystemLibrary(L"AdvApi32.dll", &vhAdvApi32Dll);
    ExitOnFailure(hr, "Failed to load AdvApi32.dll");

    // ignore failures - if this doesn't exist, we'll fall back to RegDeleteKeyW
    vpfnRegDeleteKeyExWFromLibrary = reinterpret_cast<PFN_REGDELETEKEYEXW>(::GetProcAddress(vhAdvApi32Dll, "RegDeleteKeyExW"));

    if (NULL == vpfnRegDeleteKeyExW)
    {
        vpfnRegDeleteKeyExW = vpfnRegDeleteKeyExWFromLibrary;
    }

    vfRegInitialized = TRUE;

LExit:
    return hr;
}
Exemplo n.º 7
0
extern "C" HRESULT DAPI GetCryptProvFromCert(
      __in_opt HWND hwnd,
      __in PCCERT_CONTEXT pCert,
      __out HCRYPTPROV *phCryptProv,
      __out DWORD *pdwKeySpec,
      __in BOOL *pfDidCryptAcquire,
      __deref_opt_out LPWSTR *ppwszTmpContainer,
      __deref_opt_out LPWSTR *ppwszProviderName,
      __out DWORD *pdwProviderType
      )
{
    HRESULT hr = S_OK;
    HMODULE hMsSign32 = NULL;

    typedef BOOL (WINAPI *GETCRYPTPROVFROMCERTPTR)(HWND, PCCERT_CONTEXT, HCRYPTPROV*, DWORD*,BOOL*,LPWSTR*,LPWSTR*,DWORD*);
    GETCRYPTPROVFROMCERTPTR pGetCryptProvFromCert = NULL;

    hr = LoadSystemLibrary(L"MsSign32.dll", &hMsSign32);
    ExitOnFailure(hr, "Failed to get handle to MsSign32.dll");

    pGetCryptProvFromCert = (GETCRYPTPROVFROMCERTPTR)::GetProcAddress(hMsSign32, "GetCryptProvFromCert");
    ExitOnNullWithLastError(hMsSign32, hr, "Failed to get handle to MsSign32.dll");

    if (!pGetCryptProvFromCert(hwnd,
                               pCert,
                               phCryptProv,
                               pdwKeySpec,
                               pfDidCryptAcquire,
                               ppwszTmpContainer,
                               ppwszProviderName,
                               pdwProviderType))
    {
        ExitWithLastError(hr, "Failed to get CSP from cert.");
    }
LExit:
    return hr;
}
Exemplo n.º 8
0
/********************************************************************
DetectIsCompositionEnabled

 Set a property based on the return value of DwmIsCompositionEnabled().
********************************************************************/
static HRESULT DetectIsCompositionEnabled()
{
    HRESULT hr = S_OK;
    HMODULE hModule = NULL;
    BOOL compositionState = false;

    // Manually load the d3d9.dll library. If the library can't load it's likely because we are not on a Vista
    // OS. Just return ok, and the property won't get set.
    hr = LoadSystemLibrary(L"dwmapi.dll", &hModule);
    if (E_MODNOTFOUND == hr)
    {
        TraceError(hr, "Unable to load Vista desktop window manager APIs, skipping Composition Enabled check.");
        ExitFunction1(hr = S_OK);
    }
    ExitOnFailure(hr, "Failed to load the existing window manager APIs.");

    // If for some reason we can't get the function pointer that's ok, just return.
    typedef HRESULT (WINAPI *DWMISCOMPOSITIONENABLEDPTR)(BOOL*);
    DWMISCOMPOSITIONENABLEDPTR DwmIsCompositionEnabledPtr = (DWMISCOMPOSITIONENABLEDPTR)::GetProcAddress(hModule, "DwmIsCompositionEnabled");
    ExitOnNull(hModule, hr, S_OK, "Unable to obtain function information, skipping Composition Enabled check.");
    
    hr = DwmIsCompositionEnabledPtr(&compositionState);
    ExitOnFailure(hr, "Failed to retrieve Composition state");

    if (compositionState)
    {
        hr = WcaSetIntProperty(L"WIX_DWM_COMPOSITION_ENABLED", 1);
        ExitOnFailure(hr, "Failed write property");
    }

LExit:
    if (NULL != hModule)
    {
        FreeLibrary(hModule);
    }
    return hr;
}
Exemplo n.º 9
0
extern "C" HRESULT DAPI FreeCryptProvFromCert(
    __in BOOL fAcquired,
    __in HCRYPTPROV hProv,
    __in_opt LPWSTR pwszCapiProvider,
    __in DWORD dwProviderType,
    __in_opt LPWSTR pwszTmpContainer
    )
{
    HRESULT hr = S_OK;
    HMODULE hMsSign32 = NULL;

    typedef void (WINAPI *FREECRYPTPROVFROMCERT)(BOOL, HCRYPTPROV, LPWSTR, DWORD, LPWSTR);
    FREECRYPTPROVFROMCERT pFreeCryptProvFromCert = NULL;

    hr = LoadSystemLibrary(L"MsSign32.dll", &hMsSign32);
    ExitOnFailure(hr, "Failed to get handle to MsSign32.dll");

    pFreeCryptProvFromCert = (FREECRYPTPROVFROMCERT)::GetProcAddress(hMsSign32, "FreeCryptProvFromCert");
    ExitOnNullWithLastError(hMsSign32, hr, "Failed to get handle to MsSign32.dll");

    pFreeCryptProvFromCert(fAcquired, hProv, pwszCapiProvider, dwProviderType, pwszTmpContainer);
LExit:
    return hr;
}
Exemplo n.º 10
0
//Заполнение списка метаданных
BOOL CMetadata::Load(CString csFileName)
{
	m_csConfigPath=csFileName;

	Clear();

	if(!bIsLibrary)
		LoadSystemLibrary();

	if(!OpenZip(OPEN_LOAD))
		return 0;


	int nEntries=m_zip.GetNoEntries();
	for (WORD i = 0; i < nEntries; i++)
	{
		CZipFileHeader fhInfo;
		m_zip.GetFileInfo(fhInfo, i);
		CString Str=fhInfo.GetFileName()+"\\";

		if(!m_zip.IsFileDirectory(i))
			AddToMeta(fhInfo.GetFileName());

		int nPoint=Str.ReverseFind('.');
		CString csExt;
		if(nPoint>0)
		{
			csExt=mUpper(Str.Mid(nPoint));
			csExt.TrimRight('\\');
		}
		if(csExt==".INF")
			Str=Str.Left(nPoint)+"\\";

		int nIndex1=Str.Find("\\");
		if(nIndex1>0)
		{
			int nIndex2=Str.Find("\\",nIndex1+1);
			if(nIndex2>0)
			{
				CString Str2=Str.Left(nIndex2);
				int n=Str2.ReverseFind('\\');
				CString csName=Str2.Mid(n+1);
				CString csType=mUpper(Str2.Left(n));
				if(csType==mUpper(OBJECTSNAME))
				{
					csName.TrimRight();
					if(csName.IsEmpty())
						continue;

					if(!ListObjectAdd[mUpper(csName)])
					{
						ListObjectAdd[mUpper(csName)]=(void*)1;
						ListObjectName.Add(csName);
					}
					//Объекты\Документ\Модули\Модуль среды исполнения.2c
					int nIndex3=Str.Find("\\",nIndex2+1);
					int nIndex4=Str.ReverseFind('.');
					int nPoint=nIndex4;
					if(nIndex4<=0)
						nIndex4=Str.Find("\\",nIndex3+1);
					if(nIndex3>0&&nIndex4>0)
					{
						CString csGroup=mUpper(Str.Mid(nIndex2+1,nIndex3-nIndex2-1));
						CString csModule=Str.Mid(nIndex3+1,nIndex4-nIndex3-1);

						csModule.TrimRight();
						if(csModule.IsEmpty())
							continue;

						ObjectDescription *pObject;
						pObject=(ObjectDescription *)OList[mUpper(csName)];
						if(!pObject)
							pObject=new ObjectDescription();

						pObject->bReadOnly=bIsLibrary;

						OList[mUpper(csName)]=pObject;
						if(csGroup==mUpper(OBJFORM))
						{
							if(csExt==".FRM")
								pObject->Add(pObject->aForms,pObject->ListFormAdd,csModule);
								//pObject->aForms.Add(csModule);
						}
						else
						if(csGroup==mUpper(OBJMODULE))
						{
							//if(csExt==".2C"&&mUpper(csModule)!=mUpper(CONFIGMODULENAME)&&mUpper(csModule)!=mUpper(ENTERPRISEMODULENAME))
							if(csExt!=".INF")
							if(mUpper(csModule)!=mUpper(CONFIGMODULENAME)&&mUpper(csModule)!=mUpper(ENTERPRISEMODULENAME))
								pObject->Add(pObject->aModule,pObject->ListModuleAdd,csModule);
								//pObject->aModule.Add(csModule);
						}
						else
						if(csGroup==mUpper(OBJMAKET))
						{
							pObject->Add(pObject->aMakets,pObject->ListMaketAdd,csModule);
							//pObject->aMakets.Add(csModule);
						}
						else
						if(csGroup==mUpper(OBJCONST))
						{
							if(pObject->Add(pObject->aConst,pObject->ListConstAdd,csModule))
							if(!aHashKeywordList[mUpper(csModule)])
							{
								aGlVariables.Add(csModule);
								aHashKeywordList[mUpper(csModule)]=(void*)1;
							}
/*
							if(!mUpper(csModule).IsEmpty())
							if(!aHashKeywordList[mUpper(csModule)])
							{
								aGlVariables.Add(csModule);
								aHashKeywordList[mUpper(csModule)]=(void*)1;
							}
							pObject->aConst.Add(csModule);*/
						}
					}
				}
/*				else
				if(csType==mUpper(METADATANAME))
				{
					if(csExt==".ATR")
					{
						ObjectDescription *pObject;
						pObject=(ObjectDescription *)OList[mUpper(csName)];
						if(!pObject)
							pObject=new ObjectDescription();
						OList[mUpper(csName)]=pObject;
						pObject->aAttrList.Add(csModule);
					}
				}
*/				else
				if(csType==mUpper(MODULESNAME))
				{
					CString csFileType=mUpper(Str2.Right(3));
					if(csFileType!=".INF")
					{
						if(csFileType==".2C")
							csName=csName.Left(csName.GetLength()-3);
						csName.TrimRight();
						if(csName.IsEmpty())
							continue;
						if(!ListModuleAdd[mUpper(csName)])
						{
							ListModuleAdd[mUpper(csName)]=(void*)1;
							ListModuleName.Add(csName);
						}
					}
				}
				else
				if(csType==mUpper(FORMSNAME))
				{
					CString csFileType=mUpper(Str2.Right(4));
					if(csFileType==".FRM")
					{
						csName=csName.Left(csName.GetLength()-4);
						csName.TrimRight();
						if(csName.IsEmpty())
							continue;
						if(!ListFormAdd[mUpper(csName)])
						{
							ListFormAdd[mUpper(csName)]=(void*)1;
							ListFormName.Add(csName);
						}
					}
				}
				else
				if(csType==mUpper(MAKETSNAME))
				{
					csName.TrimRight();
					if(csName.IsEmpty())
						continue;
					if(!ListMaketAdd[mUpper(csName)])
					{
						ListMaketAdd[mUpper(csName)]=(void*)1;
						ListMaketName.Add(csName);
					}
				}
			}
		}
	}

	SortList(ListFormName);
	SortList(ListMaketName);
	SortList(ListModuleName);
	SortList(ListObjectName);
//	SortList(ListMetadataName);

	OpenZip(CLOSE_FILE); //временное закрытие
	return TRUE;
}
Exemplo n.º 11
0
/********************************************************************
 PrintEula - Custom Action entry point

********************************************************************/
extern "C" UINT __stdcall PrintEula(MSIHANDLE hInstall)
{
    //AssertSz(FALSE, "Debug PrintEula");

    HRESULT hr = S_OK;
    HWND hWndMain = NULL;
    HMODULE hRichEdit = NULL;
    BOOL fRegisteredClass = FALSE;

    hr = WcaInitialize(hInstall, "PrintEula");
    ExitOnFailure(hr, "failed to initialize");

    // Initialize then display print dialog.
    vpPrintDlg = (PRINTDLGEXW*)GlobalAlloc(GPTR, sizeof(PRINTDLGEXW)); // MSDN says to allocate on heap.
    ExitOnNullWithLastError(vpPrintDlg, hr, "Failed to allocate memory for print dialog struct.");

    vpPrintDlg->lStructSize = sizeof(PRINTDLGEX);
    vpPrintDlg->hwndOwner = ::FindWindowW(L"MsiDialogCloseClass", NULL);
    vpPrintDlg->Flags = PD_RETURNDC | PD_COLLATE | PD_NOCURRENTPAGE | PD_ALLPAGES | PD_NOPAGENUMS | PD_NOSELECTION;
    vpPrintDlg->nCopies = NO_OF_COPIES;
    vpPrintDlg->nStartPage = START_PAGE_GENERAL;

    hr = ::PrintDlgExW(vpPrintDlg);
    ExitOnFailure(hr, "Failed to show print dialog");

    // If user said they want to print.
    if (PD_RESULT_PRINT == vpPrintDlg->dwResultAction)
    {
        // Get the stream for Eula
        hr = ReadEulaText(hInstall, &vpszEulaText);
        ExitOnFailure(hr, "failed to read Eula text from MSI database");

        // Have to load Rich Edit since we'll be creating a Rich Edit control in the window
        hr = LoadSystemLibrary(L"Riched20.dll", &hRichEdit);
        ExitOnFailure(hr, "failed to load rich edit 2.0 library");

        hr = CreateRichTextWindow(&hWndMain, &fRegisteredClass);
        ExitOnFailure(hr, "failed to create rich text window for printing");

        hr = PrintRichText(hWndMain);
        if (FAILED(hr)) // Since we've already shown the print dialog, we better show them a dialog explaining why it didn't print
        {
            ShowErrorMessage(hr);
        }
    }

LExit:
    ReleaseNullStr(vpszEulaText);
    if (vpPrintDlg)
    {
        if (vpPrintDlg->hDevMode)
        {
            ::GlobalFree(vpPrintDlg->hDevMode);
        }

        if (vpPrintDlg->hDevNames)
        {
            ::GlobalFree(vpPrintDlg->hDevNames);
        }

        if (vpPrintDlg->hDC)
        {
            ::DeleteDC(vpPrintDlg->hDC);
        }

        ::GlobalFree(vpPrintDlg);
        vpPrintDlg = NULL;
    }

    if (fRegisteredClass)
    {
        ::UnregisterClassW(WINDOW_CLASS, NULL);
    }

    if (NULL != hRichEdit)
    {
        ::FreeLibrary(hRichEdit);
    }

    // Always return success since we dont want to stop the
    // installation even if the Eula printing fails.
    return WcaFinalize(ERROR_SUCCESS);
}
Exemplo n.º 12
0
CLSModule * CompileCAR(const char *pszName, DWORD attribs)
{
    CLSModule *pModule;
    char *psztmp;
    int len;

    if (!(attribs & Command_s_NoSys)) {
        if (LoadSystemLibrary(attribs & Command_e_NoElastos) < 0) {
            return NULL;
        }
    }

    pModule = CreateCLS();
    if (!pModule) {
        fprintf(stderr, "[ERROR] carc (0x1001) : Out of memory.\n");
        return NULL;
    }

    if (attribs & Command_w_SuppWarn)
        SuppressWarning();
    if (attribs & Command_t_Warn2Err)
        TreatWarningAsError();
    if (attribs & Command_e_NoElastos)
        DisableWarning(0x000f);
    if (attribs & Command_a_Compress)
        pModule->mAttribs |= CARAttrib_compress;
    if (attribs & Command_A_FreeModel)
        SetDefaultThreadModel(ClassAttrib_naked);
    if (attribs & Command_i_IgrName)
        s_bLenientNaming = true;
    if (attribs & Command_k_InKernel)
        s_bInKernel = true;
    if (attribs & Command_d_Depend) {
        s_bMakeDependence = true;
        len = strlen(pszName);
        psztmp = new char[len + 1];
        if (!psztmp) {
            fprintf(stderr, "[ERROR] carc (0x1002) : Out of memory.\n");
            return NULL;
        }
        GetNakedFileName(pszName, psztmp);
        psztmp[len - 4] = '\0';
        strcat(psztmp, ".rsc");
        GenCarDependences(psztmp, 0);
        delete psztmp;
    }
    if (attribs & Command_u_WeakRef)
        s_bSupportWeakRef = true;
    if (attribs & Command_n_NakedMode)
        s_bInNakedMode = true;

    InitNamespace();

    // compiling
    //
    DoCompiling(pszName, pModule);

    UninitNamespace();

    if (0 != g_nErrorNumber) {
        fprintf(stderr, "[INFO] carc (0x1003) : Aborting compilation.\n");
        DestroyCLS(pModule);
        return NULL;
    }

    len = strlen(pszName);
    psztmp = new char[len + 1];
    if (!psztmp) {
        fprintf(stderr, "[ERROR] carc (0x1002) : Out of memory.\n");
        return NULL;
    }
    GetNakedFileName(pszName, psztmp);
    psztmp[len - 4] = '\0';
    strcat(psztmp, ".tmp");
    if (CLS2CAR(psztmp, pModule) < 0) {
        delete[] psztmp;
        fprintf(stderr, "[ERROR] carc (0x1002) : Generate temp file for generate checksum code error.\n");
        return NULL;
    }

    if (!GenCarChecksum(psztmp, pModule)) {
        delete[] psztmp;
        fprintf(stderr, "[ERROR] carc (0x1002) : Generate Rabin checksum code error.\n");
        return NULL;
    }

    if (!GenCarBarcode(pModule)) {
        fprintf(stderr, "[ERROR] carc (0x1002) : Generate barcode error.\n");
        return NULL;
    }

    delete[] psztmp;
    return pModule;
}