您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ wcscpy_s函数代码示例

51自学网 2021-06-03 09:53:45
  C++
这篇教程C++ wcscpy_s函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中wcscpy_s函数的典型用法代码示例。如果您正苦于以下问题:C++ wcscpy_s函数的具体用法?C++ wcscpy_s怎么用?C++ wcscpy_s使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了wcscpy_s函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: wmain

int wmain(int argc, _TCHAR* argv[]){	//******** NSudoInitialize Start ********	NSudoReturnMessage(TextRes.NSudo_AboutText);		if (argc == 1) bGUIMode = true;	SetProcessDPIAware();	GetModuleFileNameW(NULL, szAppPath, 260);	wcsrchr(szAppPath, L'//')[0] = NULL;	wcscpy_s(szShortCutListPath, 260, szAppPath);	wcscat_s(szShortCutListPath, 260, L"//ShortCutList.ini");	if (!SetCurrentProcessPrivilege(SE_DEBUG_NAME, true))	{		if (bGUIMode)		{			wchar_t szExePath[260];			GetModuleFileNameW(NULL, szExePath, 260);						ShellExecuteW(NULL, L"runas", szExePath, NULL, NULL, SW_SHOW);			return 0;		}		else		{			NSudoReturnMessage(TextRes.NSudo_Error_Text1);			return -1;		}	}	//******** NSudoInitialize End ********		if (bGUIMode)	{		FreeConsole();		DialogBoxParamW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDD_NSudoDlg), NULL, NSudoDlgCallBack, 0L);	}	else	{		bool bUserArgEnable = true;		bool bPrivilegeArgEnable = true;		bool bIntegrityArgEnable = true;		bool bCMDLineArgEnable = true;		wchar_t *szBuffer = NULL;		HANDLE hUserToken = INVALID_HANDLE_VALUE;		for (int i = 1; i < argc; i++)		{			if (_wcsicmp(argv[i], L"-?") == 0)			{				NSudoReturnMessage(TextRes.NSudoC_HelpText);				return 0;			}			else if (bUserArgEnable && _wcsicmp(argv[i], L"-U:T") == 0)			{				NSudoGetTrustedInstallerToken(&hUserToken);				bUserArgEnable = false;			}			else if (bUserArgEnable && _wcsicmp(argv[i], L"-U:S") == 0)			{				NSudoGetSystemToken(&hUserToken);				bUserArgEnable = false;			}			else if (bUserArgEnable && _wcsicmp(argv[i], L"-U:C") == 0)			{				NSudoGetCurrentUserToken(&hUserToken);				bUserArgEnable = false;			}			else if (bUserArgEnable && _wcsicmp(argv[i], L"-U:P") == 0)			{				NSudoGetCurrentProcessToken(&hUserToken);				bUserArgEnable = false;			}			else if (bUserArgEnable && _wcsicmp(argv[i], L"-U:D") == 0)			{				NSudoCreateLUAToken(&hUserToken);				bUserArgEnable = false;			}			else if (bPrivilegeArgEnable && _wcsicmp(argv[i], L"-P:E") == 0)			{				NSudoAdjustAllTokenPrivileges(hUserToken, true);				bPrivilegeArgEnable = false;			}			else if (bPrivilegeArgEnable && _wcsicmp(argv[i], L"-P:D") == 0)			{				NSudoAdjustAllTokenPrivileges(hUserToken, false);				bPrivilegeArgEnable = false;			}			else if (bIntegrityArgEnable && _wcsicmp(argv[i], L"-M:S") == 0)			{				SetTokenIntegrity(hUserToken, L"S-1-16-16384");				bIntegrityArgEnable = false;			}//.........这里部分代码省略.........
开发者ID:azraelrabbit,项目名称:NSudo,代码行数:101,


示例2: DecodeIL

//.........这里部分代码省略.........        printf("%s ", opcode.name);        switch(opcode.args)        {        case InlineNone: break;                case ShortInlineVar:            printf("VAR OR ARG %d",readData<BYTE>()); break;        case InlineVar:            printf("VAR OR ARG %d",readData<unsigned short>()); break;        case InlineI:            printf("%d",readData<long>());             break;        case InlineR:            printf("%f",readData<double>());            break;        case InlineBrTarget:            printf("IL_%04x",readData<long>() + position); break;        case ShortInlineBrTarget:            printf("IL_%04x",readData<BYTE>()  + position); break;        case InlineI8:            printf("%ld", readData<__int64>()); break;                    case InlineMethod:        case InlineField:        case InlineType:        case InlineTok:        case InlineSig:                {            long l = readData<long>();            if (pImport != NULL)            {                DisassembleToken(pImport, l);            }            else            {                printf("TOKEN %x", l);             }            break;        }                    case InlineString:        {            long l = readData<long>();            ULONG numChars;            WCHAR str[84];            if ((pImport != NULL) && (pImport->GetUserString((mdString) l, str, 80, &numChars) == S_OK))            {                if (numChars < 80)                    str[numChars] = 0;                wcscpy_s(&str[79], 4, W("..."));                WCHAR* ptr = str;                while(*ptr != 0) {                    if (*ptr < 0x20 || * ptr >= 0x80) {                        *ptr = '.';                    }                    ptr++;                }                printf("/"%S/"", str);            }            else            {                printf("STRING %x", l);             }            break;        }                    case InlineSwitch:        {            long cases = readData<long>();            long *pArray = new long[cases];                        long i=0;            for(i=0;i<cases;i++)            {                pArray[i] = readData<long>();            }            printf("(");            for(i=0;i<cases;i++)            {                if (i != 0)                    printf(", ");                printf("IL_%04x",pArray[i] + position);            }            printf(")");            delete [] pArray;            break;        }        case ShortInlineI:            printf("%d", readData<char>()); break;        case ShortInlineR:		            printf("%f", readData<float>()); break;        default: printf("Error, unexpected opcode type/n"); break;        }        printf("/n");    }}
开发者ID:JerryWei1985,项目名称:coreclr,代码行数:101,


示例3: wcscpy_s

void CDVSMainPPage::UpdateControlData(bool fSave){    if (fSave) {        CString fn;        m_fnedit.GetWindowText(fn);        wcscpy_s(m_fn, fn);        m_iSelectedLanguage = m_langs.GetCurSel();        m_fOverridePlacement = !!m_oplacement.GetCheck();        m_PlacementXperc = m_subposx.GetPos32();        m_PlacementYperc = m_subposy.GetPos32();        m_fOnlyShowForcedVobSubs = !!m_forcedsubs.GetCheck();        if (m_PARCombo.GetCurSel() != CB_ERR) {            m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(m_PARCombo.GetItemData(m_PARCombo.GetCurSel()));        } else {            m_ePARCompensationType = CSimpleTextSubtitle::EPCTDisabled;        }    } else {        m_fnedit.SetWindowText(CString(m_fn));        m_oplacement.SetCheck(m_fOverridePlacement);        m_subposx.SetRange32(-20, 120);        m_subposx.SetPos32(m_PlacementXperc);        m_subposx.EnableWindow(m_fOverridePlacement);        m_subposy.SetRange32(-20, 120);        m_subposy.SetPos32(m_PlacementYperc);        m_subposy.EnableWindow(m_fOverridePlacement);        m_font.SetWindowText(m_defStyle.fontName);        m_forcedsubs.SetCheck(m_fOnlyShowForcedVobSubs);        m_langs.ResetContent();        m_langs.EnableWindow(m_nLangs > 0);        for (ptrdiff_t i = 0; i < m_nLangs; i++) {            m_langs.AddString(CString(m_ppLangs[i]));        }        CorrectComboListWidth(m_langs);        m_langs.SetCurSel(m_iSelectedLanguage);        m_PARCombo.ResetContent();        m_PARCombo.InsertString(0, ResStr(IDS_RT_PAR_DISABLED));        m_PARCombo.SetItemData(0, CSimpleTextSubtitle::EPCTDisabled);        if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDisabled) {            m_PARCombo.SetCurSel(0);        }        m_PARCombo.InsertString(1, ResStr(IDS_RT_PAR_DOWNSCALE));        m_PARCombo.SetItemData(1, CSimpleTextSubtitle::EPCTDownscale);        if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDownscale) {            m_PARCombo.SetCurSel(1);        }        m_PARCombo.InsertString(2, ResStr(IDS_RT_PAR_UPSCALE));        m_PARCombo.SetItemData(2, CSimpleTextSubtitle::EPCTUpscale);        if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTUpscale) {            m_PARCombo.SetCurSel(2);        }        m_PARCombo.InsertString(3, ResStr(IDS_RT_PAR_ACCURATE_SIZE));        m_PARCombo.SetItemData(3, CSimpleTextSubtitle::EPCTAccurateSize);        if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTAccurateSize) {            m_PARCombo.SetCurSel(3);        }    }}
开发者ID:KhR0N1K,项目名称:mpc-hc,代码行数:62,


示例4: ListViewSubProc

LRESULT CALLBACK ListViewSubProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ){	switch( msg )	{		// This will essentially reconstruct the string that the open file dialog box creates when selecting multiple files.		case WM_DROPFILES:		{			int count = DragQueryFile( ( HDROP )wParam, -1, NULL, 0 );			pathinfo *pi = ( pathinfo * )malloc( sizeof( pathinfo ) );			pi->type = 0;			pi->filepath = NULL;			pi->offset = 0;			pi->output_path = NULL;			cmd_line = 0;			int file_offset = 0;	// Keeps track of the last file in filepath.			// Go through the list of paths.			for ( int i = 0; i < count; i++ )			{				// Get the length of the file path.				int file_path_length = DragQueryFile( ( HDROP )wParam, i, NULL, 0 );				// Get the file path.				wchar_t *fpath = ( wchar_t * )malloc( sizeof( wchar_t ) * ( file_path_length + 1 ) );				DragQueryFile( ( HDROP )wParam, i, fpath, file_path_length + 1 );				// Skip any folders that were dropped.				if ( ( GetFileAttributes( fpath ) & FILE_ATTRIBUTE_DIRECTORY ) != 0 )				{					free( fpath );					continue;				}				// Copy the root directory into filepath.				if ( pi->filepath == NULL )				{					pi->filepath = ( wchar_t * )malloc( sizeof( wchar_t ) * ( ( MAX_PATH * count ) + 1 ) );					pi->offset = file_path_length;					// Find the last occurance of "/" in the string.					while ( pi->offset != 0 && fpath[ --pi->offset ] != L'//' );					// Save the root directory name.					wcsncpy_s( pi->filepath, pi->offset + 1, fpath, pi->offset );					file_offset = ( ++pi->offset );				}				// Copy the file name. Each is separated by the NULL character.				wcscpy_s( pi->filepath + file_offset, file_path_length - pi->offset + 1, fpath + pi->offset );				file_offset += ( file_path_length - pi->offset + 1 );				free( fpath );			}			DragFinish( ( HDROP )wParam );			if ( pi->filepath != NULL )			{				// Terminate the last concatenated string.				wmemset( pi->filepath + file_offset, L'/0', 1 );				// filepath will be freed in the thread.				CloseHandle( ( HANDLE )_beginthreadex( NULL, 0, &read_thumbcache, ( void * )pi, 0, NULL ) );			}			else	// No files were dropped.			{				free( pi );			}			return 0;		}		break;	}	// Everything that we don't handle gets passed back to the parent to process.	return CallWindowProc( ListViewProc, hWnd, msg, wParam, lParam );}
开发者ID:bennyhendra,项目名称:thumbcache-viewer,代码行数:79,


示例5: Trace

//.........这里部分代码省略.........                            }                            catch(...)                            {                                hr = E_UNEXPECTED;                                Trace(TRACE_LEVEL_ERROR, "Failed to allocate memory for instance ID temp string, hr = %!HRESULT!", hr);                                if (nullptr != tempStr)                                 {                                    delete[] tempStr;                                }                            }                            if (SUCCEEDED(hr) && SUCCEEDED(pWdfDevice->RetrieveDeviceInstanceId(NULL, &ulCchInstanceId)))                            {                                if (SUCCEEDED(pWdfDevice->RetrieveDeviceInstanceId(wszInstanceId, &ulCchInstanceId)))                                {                                    HDEVINFO hDeviceInfo = INVALID_HANDLE_VALUE;                                    if (INVALID_HANDLE_VALUE != (hDeviceInfo = ::SetupDiCreateDeviceInfoList(NULL, NULL)))                                    {                                        SP_DEVINFO_DATA deviceInfo = {sizeof(SP_DEVINFO_DATA)};                                        if (TRUE == ::SetupDiOpenDeviceInfo(hDeviceInfo, wszInstanceId, NULL, 0, &deviceInfo))                                        {                                            DEVPROPTYPE propType;                                            ULONG ulSize;                                                            fResult = ::SetupDiGetDeviceProperty(hDeviceInfo, &deviceInfo, &DEVPKEY_Device_DeviceDesc, &propType, (PBYTE)tempStr, MAX_PATH*sizeof(WCHAR), &ulSize, 0);                                            if (FALSE == fResult)                                            {                                                hr = HRESULT_FROM_WIN32(GetLastError());                                            }                                            if (SUCCEEDED(hr) && (wcscmp(tempStr, L"") != 0))                                            {                                                wcscpy_s(m_pSensorManager->m_wszDeviceName, MAX_PATH, tempStr);                                            }                                            DWORD dwRequiredSize;                                            fResult = ::SetupDiGetDeviceInstanceId(hDeviceInfo, &deviceInfo, wszInstanceId, MAX_PATH, &dwRequiredSize);                                            if (FALSE == fResult)                                            {                                                hr = HRESULT_FROM_WIN32(GetLastError());                                            }                                            if (SUCCEEDED(hr))                                            {                                                hr = m_pSensorManager->StringTrim(wszInstanceId);                                            }                                            if (SUCCEEDED(hr))                                            {                                                wcscpy_s(m_pSensorManager->m_wszDeviceId, MAX_PATH, wszInstanceId);                                                hr = m_pSensorManager->Start();                                                if (FAILED(hr))                                                {                                                    Trace(TRACE_LEVEL_CRITICAL, "Failed to initialize sensors, hr = %!HRESULT!", hr);                                                }                                            }                                        }                                                        fResult = ::SetupDiDestroyDeviceInfoList(hDeviceInfo);                                        if (FALSE == fResult)                                        {                                            hr = HRESULT_FROM_WIN32(GetLastError());                                        }                                    }
开发者ID:uri247,项目名称:wdk80,代码行数:67,


示例6: EmitFiles

//.........这里部分代码省略.........            {                ((Assembler*)m_pAssembler)->EmitCustomAttributes(pComType->tkTok, &(pComType->m_CustomDescrList));            }        }        // Emit all manifest resources        m_dwMResSizeTotal = 0;        m_dwMResNum = 0;        for(i = 0; (pManRes = m_ManResLst.PEEK(i)); i++)        {            BOOL fOK = TRUE;            mdToken     tkImplementation = mdFileNil;            if(!pManRes->m_fNew) continue;            pManRes->m_fNew = FALSE;            WszMultiByteToWideChar(g_uCodePage,0,pManRes->szAlias,-1,wzUniBuf,dwUniBuf);            if(pManRes->szAsmRefName)            {                tkImplementation = GetAsmRefTokByName(pManRes->szAsmRefName);                if(RidFromToken(tkImplementation)==0)                {                    report->error("Undefined AssemblyRef '%s' in MResource '%s'/n",pManRes->szAsmRefName,pManRes->szName);                    fOK = FALSE;                }            }            else if(pManRes->szFileName)            {                tkImplementation = GetFileTokByName(pManRes->szFileName);                if(RidFromToken(tkImplementation)==0)                {                    report->error("Undefined File '%s' in MResource '%s'/n",pManRes->szFileName,pManRes->szName);                    fOK = FALSE;                }            }            else // embedded mgd.resource, go after the file            {                HANDLE hFile = INVALID_HANDLE_VALUE;                int j;                WCHAR   wzFileName[2048];                WCHAR*  pwz;                pManRes->ulOffset = m_dwMResSizeTotal;                for(j=0; (hFile == INVALID_HANDLE_VALUE)&&(pwzInputFiles[j] != NULL); j++)                {                    wcscpy_s(wzFileName,2048,pwzInputFiles[j]);                    pwz = wcsrchr(wzFileName,'//');                    if(pwz == NULL) pwz = wcsrchr(wzFileName,':');                    if(pwz == NULL) pwz = &wzFileName[0];                    else pwz++;                    wcscpy_s(pwz,2048-(pwz-wzFileName),wzUniBuf);                    hFile = WszCreateFile(wzFileName, GENERIC_READ, FILE_SHARE_READ,                             0, OPEN_EXISTING, 0, 0);                }                if (hFile == INVALID_HANDLE_VALUE)                {                    report->error("Failed to open managed resource file '%s'/n",pManRes->szAlias);                    fOK = FALSE;                }                else                {                    m_dwMResSize[m_dwMResNum] = SafeGetFileSize(hFile,NULL);                    if(m_dwMResSize[m_dwMResNum] == 0xFFFFFFFF)                    {                        report->error("Failed to get size of managed resource file '%s'/n",pManRes->szAlias);                        fOK = FALSE;                    }                    else                     {                        m_dwMResSizeTotal += m_dwMResSize[m_dwMResNum]+sizeof(DWORD);                        m_wzMResName[m_dwMResNum] = new WCHAR[wcslen(wzFileName)+1];                        wcscpy_s(m_wzMResName[m_dwMResNum],wcslen(wzFileName)+1,wzFileName);                        m_fMResNew[m_dwMResNum] = TRUE;                        m_dwMResNum++;                    }                    CloseHandle(hFile);                }            }            if(fOK || ((Assembler*)m_pAssembler)->OnErrGo)            {                WszMultiByteToWideChar(g_uCodePage,0,pManRes->szName,-1,wzUniBuf,dwUniBuf);                hr = m_pAsmEmitter->DefineManifestResource(         // S_OK or error.                        (LPCWSTR)wzUniBuf,                          // [IN] Name of the resource.                        tkImplementation,                           // [IN] mdFile or mdAssemblyRef that provides the resource.                        pManRes->ulOffset,                          // [IN] Offset to the beginning of the resource within the file.                        pManRes->dwAttr,                            // [IN] Flags.                        (mdManifestResource*)&(pManRes->tkTok));    // [OUT] Returned ManifestResource token.                if(FAILED(hr))                    report->error("Failed to define manifest resource '%s': 0x%08X/n",pManRes->szName,hr);            }        }        m_pAsmEmitter->Release();        m_pAsmEmitter = NULL;    }    else         report->error("Failed to obtain IMetaDataAssemblyEmit interface: 0x%08X/n",hr);    return hr;}
开发者ID:Anupam-,项目名称:shared-source-cli-2.0,代码行数:101,


示例7: Assert

    void* AsmJsEncoder::Encode( FunctionBody* functionBody )    {        Assert( functionBody );        mFunctionBody = functionBody;#if DBG_DUMP        AsmJsJitTemplate::Globals::CurrentEncodingFunction = mFunctionBody;#endif        AsmJsFunctionInfo* asmInfo = functionBody->GetAsmJsFunctionInfo();        FunctionEntryPointInfo* entryPointInfo = ((FunctionEntryPointInfo*)(functionBody->GetDefaultEntryPointInfo()));        // number of var on the stack + ebp + eip        mIntOffset = asmInfo->GetIntByteOffset() + GetOffset<Var>();        mDoubleOffset = asmInfo->GetDoubleByteOffset() + GetOffset<Var>();        mFloatOffset = asmInfo->GetFloatByteOffset() + GetOffset<Var>();        mSimdOffset = asmInfo->GetSimdByteOffset() + GetOffset<Var>();        NoRecoverMemoryArenaAllocator localAlloc(_u("BE-AsmJsEncoder"), GetPageAllocator(), Js::Throw::OutOfMemory);        mLocalAlloc = &localAlloc;        mRelocLabelMap = Anew( mLocalAlloc, RelocLabelMap, mLocalAlloc );        mTemplateData = AsmJsJitTemplate::InitTemplateData();        mEncodeBufferSize = GetEncodeBufferSize(functionBody);        mEncodeBuffer = AnewArray((&localAlloc), BYTE, mEncodeBufferSize);        mPc = mEncodeBuffer;        mReader.Create( functionBody );        ip = mReader.GetIP();#ifdef ENABLE_DEBUG_CONFIG_OPTIONS        if( PHASE_TRACE( Js::AsmjsEncoderPhase, mFunctionBody ) )        {            Output::Print( _u("/n/n") );            functionBody->DumpFullFunctionName();            Output::Print( _u("/n StackSize = %d , Offsets: Var = %d, Int = %d, Double = %d/n"), mFunctionBody->GetAsmJsFunctionInfo()->GetTotalSizeinBytes(), GetOffset<Var>(), GetOffset<int>(), GetOffset<double>() );        }#endif        AsmJsJitTemplate::FunctionEntry::ApplyTemplate( this, mPc );        while( ReadOp() ){}        AsmJsJitTemplate::FunctionExit::ApplyTemplate( this, mPc );        AsmJsJitTemplate::FreeTemplateData( mTemplateData );#if DBG_DUMP        AsmJsJitTemplate::Globals::CurrentEncodingFunction = nullptr;#endif        ApplyRelocs();        ptrdiff_t codeSize = mPc - mEncodeBuffer;        if( codeSize > 0 )        {            Assert( ::Math::FitsInDWord( codeSize ) );            BYTE *buffer;            EmitBufferAllocation *allocation = GetCodeGenAllocator()->emitBufferManager.AllocateBuffer( codeSize, &buffer, 0, 0 );            functionBody->GetAsmJsFunctionInfo()->mTJBeginAddress = buffer;            if (buffer == nullptr)            {                Js::Throw::OutOfMemory();            }            if (!GetCodeGenAllocator()->emitBufferManager.CommitBuffer(allocation, buffer, codeSize, mEncodeBuffer))            {                Js::Throw::OutOfMemory();            }            functionBody->GetScriptContext()->GetThreadContext()->SetValidCallTargetForCFG(buffer);            // TODO: improve this once EntryPoint cleanup work is complete!#if 0            const char16 *const functionName = functionBody->GetDisplayName();            const char16 *const suffix = _u("TJ");            char16 functionNameArray[256];            const size_t functionNameCharLength = functionBody->GetDisplayNameLength();            wcscpy_s(functionNameArray, 256, functionName);            wcscpy_s(&functionNameArray[functionNameCharLength], 256 - functionNameCharLength, suffix);#endif            JS_ETW(EventWriteMethodLoad(functionBody->GetScriptContext(),                (void *)buffer,                codeSize,                EtwTrace::GetFunctionId(functionBody),                0 /* methodFlags - for future use*/,                MethodType_Jit,                EtwTrace::GetSourceId(functionBody),                functionBody->GetLineNumber(),                functionBody->GetColumnNumber(),                functionBody->GetDisplayName()));            entryPointInfo->SetTJCodeGenDone(); // set the codegen to done state for TJ            entryPointInfo->SetCodeSize(codeSize);            return buffer;        }        return nullptr;    }
开发者ID:Rastaban,项目名称:ChakraCore,代码行数:91,


示例8: OutOfProcessExceptionEventCallback

HRESULT WINAPIOutOfProcessExceptionEventCallback (  /* __in    */ PVOID pContext,  /* __in    */ const PWER_RUNTIME_EXCEPTION_INFORMATION pExceptionInformation,  /* __out   */ BOOL *pbOwnershipClaimed,  /* __out   */ PWSTR pwszEventName,  /* __inout */ PDWORD pchSize,  /* __out   */ PDWORD pdwSignatureCount)/*++Routine Description:    WER calls this function to determine whether the exception handler is claiming the crash.    We will check if this is an exception we should handle (0xABCD1234).    The PFN_WER_RUNTIME_EXCEPTION_EVENT type defines a pointer to this callback function.    This function will be exported out of this DLL, as specified by HandlerDll.def.Arguments:    pContext - An arbitrary pointer-sized value that was passed in to WerRegisterRuntimeExceptionModule.    pExceptionInformation - A WER_RUNTIME_EXCEPTION_INFORMATION structure that contains the exception        information. Use the information to determine whether you want to claim the crash.    pbOwnershipClaimed - Set to TRUE if you are claiming the crash; otherwise, FALSE. If you return FALSE,        do not set the rest of the out parameters.    pwszEventName - A caller-allocated buffer that you use to specify the event name used to identify this        crash.    pchSize - A pointer to a DWORD specifying the size, in characters, of the pwszEventName buffer. The size        includes the null-terminating character.    pdwSignatureCount - The number of report parameters that you will provide. The valid range of values is        one to 10. If you specify a value greater than 10, WER will ignore the value and collect only the        first 10 parameters. If you specify zero, the reporting process will be indeterminate.        This value determines the number of times that WER calls your OutOfProcessExceptionEventSignature-        Callback function.Return Value:    HRESULT.--*/{    PCWSTR EventName = L"MySampleEventName";    DWORD EventNameLength;    UNREFERENCED_PARAMETER (pContext);    //    // Bail out if it is not an exception we want to handle.    //    if (0xABCD1234 != pExceptionInformation->exceptionRecord.ExceptionCode) {        *pbOwnershipClaimed = FALSE;        return S_OK;    }    //    // Claim the exception. We will use 2 signature pairs to uniquely identify our exception.    //    *pbOwnershipClaimed = TRUE;    *pdwSignatureCount = 2;    //    // See if the event name buffer given is big enough to hold the event name, and the null-terminator.    //    EventNameLength = (DWORD) (1 + wcslen (EventName));    if (*pchSize < EventNameLength) {        *pchSize = EventNameLength;        return HRESULT_FROM_WIN32 (ERROR_INSUFFICIENT_BUFFER);    }    //    // Copy the event name we use.    //    wcscpy_s (pwszEventName, *pchSize, EventName);    return S_OK;}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:90,


示例9: WndProc

////  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)////  PURPOSE:  Processes messages for the main window.//LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,                         LPARAM lParam) {  static HWND backWnd = NULL, forwardWnd = NULL, reloadWnd = NULL,      stopWnd = NULL, editWnd = NULL;  static WNDPROC editWndOldProc = NULL;  // Static members used for the find dialog.  static FINDREPLACE fr;  static WCHAR szFindWhat[80] = {0};  static WCHAR szLastFindWhat[80] = {0};  static bool findNext = false;  static bool lastMatchCase = false;  int wmId, wmEvent;  PAINTSTRUCT ps;  HDC hdc;  if (hWnd == editWnd) {    // Callback for the edit window    switch (message) {    case WM_CHAR:      if (wParam == VK_RETURN && g_handler.get()) {        // When the user hits the enter key load the URL        CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();        wchar_t strPtr[MAX_URL_LENGTH+1] = {0};        *((LPWORD)strPtr) = MAX_URL_LENGTH;        LRESULT strLen = SendMessage(hWnd, EM_GETLINE, 0, (LPARAM)strPtr);        if (strLen > 0) {          strPtr[strLen] = 0;          browser->GetMainFrame()->LoadURL(strPtr);        }        return 0;      }    }    return (LRESULT)CallWindowProc(editWndOldProc, hWnd, message, wParam,                                   lParam);  } else if (message == uFindMsg) {    // Find event.    LPFINDREPLACE lpfr = (LPFINDREPLACE)lParam;    if (lpfr->Flags & FR_DIALOGTERM) {      // The find dialog box has been dismissed so invalidate the handle and      // reset the search results.      hFindDlg = NULL;      if (g_handler.get()) {        g_handler->GetBrowser()->GetHost()->StopFinding(true);        szLastFindWhat[0] = 0;        findNext = false;      }      return 0;    }    if ((lpfr->Flags & FR_FINDNEXT) && g_handler.get())  {      // Search for the requested string.      bool matchCase = (lpfr->Flags & FR_MATCHCASE?true:false);      if (matchCase != lastMatchCase ||          (matchCase && wcsncmp(szFindWhat, szLastFindWhat,              sizeof(szLastFindWhat)/sizeof(WCHAR)) != 0) ||          (!matchCase && _wcsnicmp(szFindWhat, szLastFindWhat,              sizeof(szLastFindWhat)/sizeof(WCHAR)) != 0)) {        // The search string has changed, so reset the search results.        if (szLastFindWhat[0] != 0) {          g_handler->GetBrowser()->GetHost()->StopFinding(true);          findNext = false;        }        lastMatchCase = matchCase;        wcscpy_s(szLastFindWhat, sizeof(szLastFindWhat)/sizeof(WCHAR),            szFindWhat);      }      g_handler->GetBrowser()->GetHost()->Find(0, lpfr->lpstrFindWhat,          (lpfr->Flags & FR_DOWN)?true:false, matchCase, findNext);      if (!findNext)        findNext = true;    }    return 0;  } else {    // Callback for the main window    switch (message) {    case WM_CREATE: {      // Create the single static handler class instance      g_handler = new ClientHandler();      g_handler->SetMainHwnd(hWnd);      // Create the child windows used for navigation      RECT rect;      int x = 0;      GetClientRect(hWnd, &rect);      backWnd = CreateWindow(L"BUTTON", L"Back",                              WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON//.........这里部分代码省略.........
开发者ID:johndpope,项目名称:UE4,代码行数:101,


示例10: LV_ThemFie

// Them cac tap tin trong thu muc duoc chi dinh vao ListView// Index bat dau cua cac tap tin duoc them vao ListView// Gia tri tra ve:// TRUE:	them duoc file vao ListView// FALSE:	khong them duoc file vao ListViewint LV_ThemFie(TCHAR* szDuongDan, int index){	WIN32_FIND_DATA FindFileData;	HANDLE hFind;	TCHAR temp[265];	LVITEM lvItem;	int nItem;	int iCount = 0; // Tong so tap tin co trong thu muc 		if (!szDuongDan)		return iCount;	wsprintf(temp, _T("%s*"), szDuongDan);	hFind = FindFirstFile(temp, &FindFileData);	if (hFind == INVALID_HANDLE_VALUE) 	{		int t = GetLastError();		if (t == 21 // O CD, Floppy disk chua co dia		  || t == 2 // Khong tim thay file nao, tuc o dia rong		  || t == 5)// Tap tin khong duoc phep truy xuat		  return iCount;		// Loi chua xac dinh		ErrorExit(_T("/"LV_ThemFile() FindFirstFile/""));	}	// La thu muc	if (wcscmp(FindFileData.cFileName, _T(".")) == 0)	{		// Bo qua thu muc ..		FindNextFile(hFind, &FindFileData);		FindNextFile(hFind, &FindFileData);	}	else; // La o dia	lvItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;	HIMAGELIST himl1 = ListView_GetImageList(hwndListView, LVSIL_SMALL);	HIMAGELIST himl2 = ListView_GetImageList(hwndListView, LVSIL_NORMAL);	SHFILEINFO psfi;	// Tim tat ca cac tap tin con 	HienHanh.iKichThuoc = 0;	do	{		// Lay tat ca cac file khong phai la thu muc		if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))		{			wsprintf(temp, _T("%s%s"), szDuongDan, FindFileData.cFileName);			SHGetFileInfo(temp, 0, &psfi, sizeof ( SHFILEINFO ), SHGFI_ICON 				| SHGFI_SMALLICON);			ImageList_AddIcon(himl1, psfi.hIcon);							SHGetFileInfo(temp, 0, &psfi, sizeof ( SHFILEINFO ), SHGFI_ICON 				| SHGFI_LARGEICON);			ImageList_AddIcon(himl2, psfi.hIcon);			++iCount;						lvItem.pszText = FindFileData.cFileName;			lvItem.iItem = index;			lvItem.iImage = ImageList_GetImageCount(himl1) - 1;			lvItem.iSubItem = 0;			// Field lParam duoc dung trong ham so sanh (pfnCompare) khi can sort item			// Truong hop nay, ta nen luu lai index cua item			lvItem.lParam = index;  			// Chen item vao ListView			nItem = ListView_InsertItem(hwndListView, &lvItem);			if(nItem == -1)					return 0;						// Them thong tin cua cac cot con lai (Col #1, #2, #3) cho item 			TCHAR szItemText[LISTVIEW_ITEM_MAX_LEN];			// Con tro ham			ham f[3] = {GetSize,						GetAttribute,						GetDateModified};			// Cong kich thuoc cua file vao kich thuoc cua thu muc						HienHanh.iKichThuoc += (FindFileData.nFileSizeHigh * (__int64(MAXDWORD) + 1)) + FindFileData.nFileSizeLow;			TCHAR *temp;			for(int c = 0; c < 3; c++)			{				temp = f[c](&FindFileData);				wcscpy_s(szItemText, temp);								LV_ITEM		lvsItem;					lvsItem.mask = LVIF_TEXT;// | LVIF_IMAGE;				lvsItem.iItem=nItem;				lvsItem.iSubItem=c + 1;				lvsItem.pszText=szItemText;			//	lvsItem.iImage=2;				ListView_SetItem(hwndListView,&lvsItem);				delete []temp;			}			++index;		}			  //.........这里部分代码省略.........
开发者ID:anhvinhitus,项目名称:myprojects2005-2009,代码行数:101,


示例11: OutOfProcessExceptionEventSignatureCallback

HRESULT WINAPIOutOfProcessExceptionEventSignatureCallback (  /* __in    */ PVOID pContext,  /* __in    */ const PWER_RUNTIME_EXCEPTION_INFORMATION pExceptionInformation,  /* __in    */ DWORD dwIndex,  /* __out   */ PWSTR pwszName,  /* __inout */ PDWORD pchName,  /* __out   */ PWSTR pwszValue,  /* __inout */ PDWORD pchValue)/*++Routine Description:    WER can call this function multiple times to get the report parameters that uniquely describe the    problem.    The PFN_WER_RUNTIME_EXCEPTION_EVENT_SIGNATURE type defines a pointer to this callback function.    This function will be exported out of this DLL, as specified by HandlerDll.def.Arguments:    pContext - An arbitrary pointer-sized value that was passed in to WerRegisterRuntimeExceptionModule.    pExceptionInformation - A WER_RUNTIME_EXCEPTION_INFORMATION structure that contains the exception        information.    dwIndex - The index of the report parameter. Valid values are 0 to 9.    pwszName - A caller-allocated buffer that you use to specify the parameter name.    pchName - A pointer to a DWORD specifying the size, in characters, of the pwszName buffer. The size includes        the null-terminating character.    pwszValue - A caller-allocated buffer that you use to specify the parameter value.    pchValue - A pointer to a DWORD specifying the size, in characters, of the pwszValue buffer. The size includes        the null-terminating character.Return Value:    HRESULT.--*/{    UNREFERENCED_PARAMETER (pContext);    //    // Some sanity checks. Our handler only specifies 2 signature pairs.    //    if (dwIndex >= 2        || (0xABCD1234 != pExceptionInformation->exceptionRecord.ExceptionCode)) {        return E_UNEXPECTED;    }    //    // Make sure the given buffers are large enough to hold our signature name/value pairs.    // We will need 4 characters (3 characters + 1 null-terminator) for our fixed strings.    //    if (*pchName < 4) {        *pchName = 4;        return HRESULT_FROM_WIN32 (ERROR_INSUFFICIENT_BUFFER);    }    if (*pchValue < 4) {        *pchValue = 4;        return HRESULT_FROM_WIN32 (ERROR_INSUFFICIENT_BUFFER);    }    //    // At this point, we should fill in the problem signature with the data from the crashing process.    //    // For example, the signature can uniquely identify where the crash happened. If our application runs    // custom-compiled code, we can let the signature identify what module/class/line/etc the crash    // happened at. This can be done by exposing an easily-accessible data structure in the process, and    // reading the structure using ReadProcessMemory.    //    // In here, we will simply set the signature to some fixed strings.    //    switch (dwIndex) {      case 0:        wcscpy_s (pwszName, *pchName, L"one");        wcscpy_s (pwszValue, *pchValue, L"111");        break;      case 1:        wcscpy_s (pwszName, *pchName, L"two");        wcscpy_s (pwszValue, *pchValue, L"222");        break;      default:        UNREACHABLE_CODE ();    }    return S_OK;//.........这里部分代码省略.........
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:101,


示例12: addInfoToListView

BOOL addInfoToListView(HTREEITEM hParent){	HIMAGELIST himl1 = ListView_GetImageList(hwndListView, LVSIL_SMALL);	HIMAGELIST himl2 = ListView_GetImageList(hwndListView, LVSIL_NORMAL);	SHFILEINFO psfi;	LV_ITEM		lvItem;		// Cau truc mo ta 1 Item cua ListView	int			nItem;	TVITEM		kq;	TCHAR		szText[PATHFILE_MAX_LEN];	int			index = 0; // index cua item cua ListView	HTREEITEM	hItem;	// Tao gia tri ban dau cho thu muc hien hanh	HienHanh.iFolderCount = 0; // So thu muc con co trong thu muc hien hanh	HienHanh.iKichThuoc = 0;	HienHanh.iFileCount = 0;	// Xoa noi dung cu cua ListView	ListView_DeleteAllItems(hwndListView);	for (int i = 0; i < ImageList_GetImageCount(himl1); ++i)	{		DestroyIcon(ImageList_GetIcon(himl1, i, 0));		DestroyIcon(ImageList_GetIcon(himl2, i, 0));	}	ImageList_RemoveAll(himl1);	ImageList_RemoveAll(himl2);	// Khoi tao cac gia tri cho item	lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;	kq.mask = TVIF_TEXT | TVIF_PARAM;	kq.pszText = szText;	kq.cchTextMax = PATHFILE_MAX_LEN;	// Them thu muc vao ListView	if (hItem = TreeView_GetChild(hwndTreeView, hParent))	{		do		{			kq.hItem = hItem;			TreeView_GetItem(hwndTreeView, &kq);						SHGetFileInfo((TCHAR*) kq.lParam, 0, &psfi, sizeof ( SHFILEINFO ), SHGFI_ICON 				| SHGFI_SMALLICON);			ImageList_AddIcon(himl1, psfi.hIcon);							SHGetFileInfo((TCHAR*) kq.lParam, 0, &psfi, sizeof ( SHFILEINFO ), SHGFI_ICON 				| SHGFI_LARGEICON);			ImageList_AddIcon(himl2, psfi.hIcon);				lvItem.pszText = szText;			lvItem.iItem = index;			lvItem.iImage = ImageList_GetImageCount(himl1) - 1;			lvItem.iSubItem = 0;						// Field lParam duoc dung trong ham so sanh (pfnCompare) khi can sort item			// Truong hop nay, ta nen luu lai index cua item			lvItem.lParam = index;  			// Chen item vao ListView			nItem = ListView_InsertItem(hwndListView, &lvItem);			if(nItem == -1)					return FALSE;				// Them thong tin cua cac cot con lai (Col #1, #2, #3) cho item //			GetDriveType			WIN32_FIND_DATA FindFileData;			TCHAR temp[PATHFILE_MAX_LEN];						// Lay duong dan cua thu muc			wcscpy_s(temp, (TCHAR*) kq.lParam);			temp[wcslen(temp) - 1] = '/0';						if (wcslen(temp) == 2 && temp[1] == ':') // O dia			{				// Thong tin cua o dia			}			else			{				HANDLE hFind = FindFirstFile(temp, &FindFileData);				if (hFind == INVALID_HANDLE_VALUE) 				{					int t = GetLastError();					if (t == 21 // O CD, Floppy disk chua co dia					  || t == 2) // Khong tim thay file nao, tuc o dia rong					  continue;					// Loi chua xac dinh					ErrorExit(_T("/"addInfoToListView() FindFirstFile/""));				}								TCHAR szItemText[LISTVIEW_ITEM_MAX_LEN];				// Con tro ham				ham f[3] = {GetSize,							GetAttribute,							GetDateModified};				++HienHanh.iFolderCount;				TCHAR *temp1;				for(int c = 0; c < 3; c++)				{					temp1 = f[c](&FindFileData);					wcscpy_s(szItemText, temp1);					//.........这里部分代码省略.........
开发者ID:anhvinhitus,项目名称:myprojects2005-2009,代码行数:101,


示例13: TV_ThemThuMucCon

// Them tat ca cac thu muc con vao TreeView tai nut dang duoc chonBOOL TV_ThemThuMucCon(TCHAR* szDuongDan, const HTREEITEM& T){	WIN32_FIND_DATA FindFileData;	HANDLE hFind;	HTREEITEM hParent = T;	HTREEITEM hPrev = NULL;	TCHAR temp[265];		wsprintf(temp, _T("%s*"), szDuongDan);	hFind = FindFirstFile(temp, &FindFileData);	if (hFind == INVALID_HANDLE_VALUE) 	{		int t = GetLastError();		if (t == 21 // O CD, Floppy disk chua co dia		  || t == 2) // Khong tim thay file nao, tuc o dia rong		  return FALSE;		// Loi chua xac dinh		ErrorExit(_T("/"ThemThuMucCon() FindFirstFile/""));	}	// La thu muc	if (wcscmp(FindFileData.cFileName, _T(".")) == 0)	{		// Bo qua thu muc ..		FindNextFile(hFind, &FindFileData);		FindNextFile(hFind, &FindFileData);	}	else; // La o dia	bool flag = false;	size_t len = wcslen(szDuongDan);	wcscpy_s(temp, szDuongDan);		// Tim tat ca cac thu muc con 	size_t len1;	do	{		// Thu muc		if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)		{			// Them vao cuoi chuoi duong dan cu ten thu muc vua tim duoc 			// va chuoi "/*" de kiem tra thu muc nay co chua thu muc con hay khong			temp[len] = 0;			wcscat_s(temp, FindFileData.cFileName);			len1 = wcslen(temp);			temp[len1] = '//';			temp[len1 + 1] = '/0';//			temp[len1 + 2] = '/0';			// Tham so szLParam trong ham addItemToTree			TCHAR *szLParam = new TCHAR[len1 + 3];			wcscpy_s(szLParam, len1 + 3, temp);			szLParam[len1 + 2] = 0; // Thong bao thu muc nay chua duoc expand lan nao			temp[len1 + 1] = '*';			temp[len1 + 2] = '/0';						// Them thu muc con vao nut cha			flag = true;									hPrev = addItemToTree(FindFileData.cFileName, szLParam, hParent, hPrev, CoChuaThuMucCon(temp));		}			  	} while (FindNextFile(hFind, &FindFileData));	FindClose(hFind);	return flag;}
开发者ID:anhvinhitus,项目名称:myprojects2005-2009,代码行数:68,


示例14: LayThongTinODia

void LayThongTinODia(TCHAR *szODia, TCHAR *szThongTin){	// Nhung bien nay dung cho ham GetVolumeInformation	TCHAR szVolumeName[256];	DWORD DWVolumeSerialNumber;	DWORD DWMaximumComponentLength;	DWORD DWFileSystemFlags;		// Tat cac thong bao loi	SetErrorMode(SEM_FAILCRITICALERRORS);	DWErr = GetVolumeInformation(szODia, 			szVolumeName, 256,			&DWVolumeSerialNumber,			&DWMaximumComponentLength,			&DWFileSystemFlags,			NULL, 0);	if (DWErr == 0)	{		if (GetLastError() == 21) // Loi khong co dia trong o dia mem hoac CD-ROM		{			UINT t = GetDriveType(szODia);			switch (t)			{			case DRIVE_CDROM:				wcscpy_s(szVolumeName, _T("CD-ROM Drive"));				break;			case DRIVE_REMOVABLE:				wcscpy_s(szVolumeName, _T("Floppy Drive"));				break;			}		}		else			ErrorExit(_T("/"GetVolumeInformation/""));			}	// Truong hop o dia khong co ten	if (_tcslen(szVolumeName) == 0)	{		UINT t = GetDriveType(szODia);		switch (t)		{		case DRIVE_CDROM:			wcscpy_s(szVolumeName, _T("CD-ROM Drive"));			break;		case DRIVE_REMOVABLE:			wcscpy_s(szVolumeName, _T("Removable Hard Disk"));			break;		case DRIVE_RAMDISK:			wcscpy_s(szVolumeName, _T("RAM Disk"));			break;		case DRIVE_FIXED:			wcscpy_s(szVolumeName, _T("Local Disk"));			break;		}	}	szODia[2] = '/0';	wsprintf(szThongTin, _T("%s (%s)"), szVolumeName, szODia); 	szODia[2] = '//';	// Bat lai cac thong bao loi	SetErrorMode(0);}
开发者ID:anhvinhitus,项目名称:myprojects2005-2009,代码行数:64,


示例15: GetObject

HRESULT CLCDMyManager::Initialize(){	LOGFONT lf;	HFONT hFont;	unsigned int x, y;	// max dims: 160 x 43	x = 10;	y = 0;	// Initialize the text control (media)	m_Text1.Initialize();	m_Text1.SetOrigin(x, y);	m_Text1.SetSize(160-x, 13);	m_Text1.SetAlignment(DT_CENTER);	m_Text1.SetWordWrap(false);	m_Text1.SetText(_T(""));	m_Text1.SetStartDelay(5000);	m_Text1.SetEndDelay(2000);	m_Text1.EnableRepeat(true);	m_Text1.SetScrollDirection(CLCDScrollingText::SCROLL_HORZ);	m_Text1.SetSpeed(24);	// Initialize the progressbar control (media progress)	y += 15;	m_ProgBar[1].Initialize();	m_ProgBar[1].SetOrigin(x+10, y);	m_ProgBar[1].SetSize(160-x-10, 7);	m_ProgBar[1].SetPos(0);	m_ProgBar[1].SetProgressStyle(CLCDProgressBar::STYLE_FILLED_H);	// gfx	m_PlayState.Initialize();	m_PlayState.SetOrigin(x, y);	m_PlayState.SetSize(7, 7);	// Initialize the text control (time / mpc messages)	y += 7;	m_Text[0].Initialize();	m_Text[0].SetOrigin(x, y);	m_Text[0].SetSize(160-x, /*13*/25);	m_Text[0].SetAlignment(DT_CENTER);	m_Text[0].SetWordWrap(false);	m_Text[0].SetText(_T(""));	m_Text[0].SetFontPointSize(7);	hFont = m_Text[0].GetFont();	GetObject(hFont, sizeof(LOGFONT), &lf);	wcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Microsoft Sans Serif"));	m_Text[0].SetFont(lf);	y += 11;	m_Text[1].Initialize();	m_Text[1].SetOrigin(x, y);	m_Text[1].SetSize(160-x, /*13*/25);	m_Text[1].SetAlignment(DT_CENTER);	m_Text[1].SetWordWrap(false);	m_Text[1].SetText(_T(""));	m_Text[1].SetFontPointSize(7);	hFont = m_Text[1].GetFont();	GetObject(hFont, sizeof(LOGFONT), &lf);	wcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Microsoft Sans Serif"));	m_Text[1].SetFont(lf);	// Initialize the progressbar control (volume)	m_ProgBar[0].Initialize();	m_ProgBar[0].SetOrigin(0, 0);	m_ProgBar[0].SetSize(7, 43);	m_ProgBar[0].SetPos(0);	m_ProgBar[0].SetProgressStyle(CLCDProgressBar::STYLE_FILLED_V);	AddObject(&m_Text1);	AddObject(&m_Text[0]);	AddObject(&m_Text[1]);	AddObject(&m_ProgBar[0]);	AddObject(&m_ProgBar[1]);	AddObject(&m_PlayState);	return CLCDManager::Initialize();}
开发者ID:Samangan,项目名称:mpc-hc,代码行数:79,


示例16: GetFileNameFromHandle

/* This function takes a handle, and provides the associated filename back */BOOL GetFileNameFromHandle(HANDLE hFile, WCHAR* fName){	BOOL bSuccess = FALSE; // Was this function successful?	TCHAR pszFilename[MAX_PATH + 1]; // Holds filename once retrieved	HANDLE hFileMap; // Handle used for the CreateFileMapping();	/* Create file mapping */	hFileMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);	if (hFileMap)	{		/* Map view of file */		void* pMem = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 1);		if (pMem)		{			/* At this point, we are able to retrieve the filename */			if (GetMappedFileName(GetCurrentProcess(), pMem, pszFilename, MAX_PATH))			{				/* Now we want to make it into the friendly format with drive lettes etc */				TCHAR szTemp[BUFSIZE];				szTemp[0] = '/0';				if (GetLogicalDriveStrings(BUFSIZE - 1, szTemp))				{					TCHAR szName[MAX_PATH];					TCHAR szDrive[3] = TEXT(" :");					BOOL bFound = FALSE;					TCHAR* p = szTemp;					do					{						// Copy the drive letter to the template string						*szDrive = *p;						// Look up each device name						if (QueryDosDevice(szDrive, szName, MAX_PATH))						{							size_t uNameLen = _tcslen(szName);							if (uNameLen < MAX_PATH)							{								bFound = _tcsnicmp(pszFilename, szName, uNameLen) == 0									&& *(pszFilename + uNameLen) == _T('//');								if (bFound)								{									// Reconstruct pszFilename using szTempFile									// Replace device path with DOS path									TCHAR szTempFile[MAX_PATH];									StringCchPrintf(szTempFile, MAX_PATH, TEXT("%s%s"), szDrive, pszFilename + uNameLen);									StringCchCopyN(pszFilename, MAX_PATH + 1, szTempFile, _tcslen(szTempFile));								}							}						}						// Go to the next NULL character.						while (*p++);					} while (!bFound && *p); // end of string				}			}			/* Function completed successfully */			bSuccess = TRUE;			UnmapViewOfFile(pMem);		}		CloseHandle(hFileMap);	}	else {		CloseHandle(hFileMap);		return bSuccess;	}	/* Copy the filename string into our _OUT_ variable */	wcscpy_s(fName, MAX_PATH, pszFilename);	return bSuccess;}
开发者ID:asiimwejob,项目名称:handle_monitor,代码行数:78,


示例17: m_hMainWnd

CMainWindow::CMainWindow(void) :    m_hMainWnd(NULL),    m_CmdShow(0){    wcscpy_s(m_szMainWndClass, 32, L"DispSleepWndClass");}
开发者ID:wyrover,项目名称:development,代码行数:6,


示例18: wmain

//.........这里部分代码省略.........				iCurrentProcess_ArrayIndex = -1;				/* Check whether we've already got an entry for the process we're looking at */				for (int j = 0; j < (MAX_PROCESSES - 1); j++)					if (iProcessArray[j][PROCESS_ARRAY_INDEX] == handle.ProcessId)						iCurrentProcess_ArrayIndex = j;				/* If not, create a new entry for the process associated with the current handle */				if (iCurrentProcess_ArrayIndex == -1)					for (int j = 0; j < (MAX_PROCESSES - 1); j++)						if (iProcessArray[j][PROCESS_ARRAY_INDEX] == -1)						{							iProcessArray[j][PROCESS_ARRAY_INDEX] = handle.ProcessId;							iCurrentProcess_ArrayIndex = j;							break;						}				/* If there's more than MAX_PROCESSES, throw an error					TODO: Tidy this up, identify number of running processes dynamically and set array size accordingly */				if (iCurrentProcess_ArrayIndex == -1)				{					printf("Error: Too many processes running!/n");					return 1;				}				/* Look through the handle array, to see whether the filename can be found */				WCHAR cCurrentHandleText[MAX_PATH];				for (int j = 0; j < (MAX_FILE_HANDLES - 1); j++)				{					/* If we hit NULL, there are no more to find, so add ours */					swprintf_s(cCurrentHandleText, MAX_PATH, L"%ls", wHandleFileName);					if (!wcscmp(cHandleArray[iCurrentProcess_ArrayIndex][j], L"")){						wcscpy_s(cHandleArray[iCurrentProcess_ArrayIndex][j], cCurrentHandleText);						break;					}					/* If we find ours, then stop searching */					else if (!wcscmp(cHandleArray[iCurrentProcess_ArrayIndex][j], cCurrentHandleText))						break;				}				/* If it's the first (or last) cycle, tally how many entries in the handle array for this					particular process we have so far */				if (iCycleCounter == 1)					for (int j = 0; j < (MAX_FILE_HANDLES - 1); j++)						if (!wcscmp(cHandleArray[iCurrentProcess_ArrayIndex][j], L"")){							iProcessArray[iCurrentProcess_ArrayIndex][PROCESS_ARRAY_COUNT_START_CYCLE] = (j - 1);							break;						}				if (iCycleCounter == dNumberCycles)					for (int j = 0; j < (MAX_FILE_HANDLES - 1); j++)						if (!wcscmp(cHandleArray[iCurrentProcess_ArrayIndex][j], L"")) {							iProcessArray[iCurrentProcess_ArrayIndex][PROCESS_ARRAY_COUNT_END_CYCLE] = (j - 1);							break;						}				free(objectTypeInfo);				free(wHandleFileName);				CloseHandle(dupHandle);				CloseHandle(processHandle);			}			free(handleInfo);			/* If the iteration pause is not 0, sleep for the requested time [Default: 1000ms] */
开发者ID:asiimwejob,项目名称:handle_monitor,代码行数:67,


示例19: FindFirstFile

bool PluginLoader::searchForPlugin(std::vector<Plugin> & newPluginList, const WCHAR * searchPath, bool isScyllaPlugin){	WIN32_FIND_DATA ffd;	HANDLE hFind = 0;	DWORD dwError = 0;	Plugin pluginData;	hFind = FindFirstFile(searchPath, &ffd);	dwError = GetLastError();	if (dwError == ERROR_FILE_NOT_FOUND)	{#ifdef DEBUG_COMMENTS		Scylla::debugLog.log(L"findAllPlugins :: No files found");#endif		return true;	}	if (hFind == INVALID_HANDLE_VALUE)	{#ifdef DEBUG_COMMENTS		Scylla::debugLog.log(L"findAllPlugins :: FindFirstFile failed %d", dwError);#endif		return false;	}	do	{		if ( !(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )		{			if ((ffd.nFileSizeHigh != 0) || (ffd.nFileSizeLow < 200))			{#ifdef DEBUG_COMMENTS				Scylla::debugLog.log(L"findAllPlugins :: Plugin invalid file size: %s", ffd.cFileName);#endif			}			else			{				pluginData.fileSize = ffd.nFileSizeLow;				wcscpy_s(pluginData.fullpath, baseDirPath);				wcscat_s(pluginData.fullpath, ffd.cFileName);#ifdef DEBUG_COMMENTS				Scylla::debugLog.log(L"findAllPlugins :: Plugin %s", pluginData.fullpath);#endif				if (isValidDllFile(pluginData.fullpath))				{					if (isScyllaPlugin)					{						if (getScyllaPluginName(&pluginData))						{							//add valid plugin							newPluginList.push_back(pluginData);						}						else						{#ifdef DEBUG_COMMENTS							Scylla::debugLog.log(L"Cannot get scylla plugin name %s", pluginData.fullpath);#endif						}					}					else					{						if (isValidImprecPlugin(pluginData.fullpath))						{							wcscpy_s(pluginData.pluginName, ffd.cFileName);							newPluginList.push_back(pluginData);						}					}				}			}		}	}	while (FindNextFile(hFind, &ffd) != 0);	dwError = GetLastError();	FindClose(hFind);	return (dwError == ERROR_NO_MORE_FILES);}
开发者ID:AlexWMF,项目名称:Scylla,代码行数:86,


示例20: read_pth_file

static intread_pth_file(const wchar_t *path, wchar_t *prefix, int *isolated, int *nosite){    FILE *sp_file = _Py_wfopen(path, L"r");    if (sp_file == NULL)        return -1;    wcscpy_s(prefix, MAXPATHLEN+1, path);    reduce(prefix);    *isolated = 1;    *nosite = 1;    size_t bufsiz = MAXPATHLEN;    size_t prefixlen = wcslen(prefix);    wchar_t *buf = (wchar_t*)PyMem_RawMalloc(bufsiz * sizeof(wchar_t));    buf[0] = '/0';    while (!feof(sp_file)) {        char line[MAXPATHLEN + 1];        char *p = fgets(line, MAXPATHLEN + 1, sp_file);        if (!p)            break;        if (*p == '/0' || *p == '#')            continue;        while (*++p) {            if (*p == '/r' || *p == '/n') {                *p = '/0';                break;            }        }        if (strcmp(line, "import site") == 0) {            *nosite = 0;            continue;        } else if (strncmp(line, "import ", 7) == 0) {            Py_FatalError("only 'import site' is supported in ._pth file");        }        DWORD wn = MultiByteToWideChar(CP_UTF8, 0, line, -1, NULL, 0);        wchar_t *wline = (wchar_t*)PyMem_RawMalloc((wn + 1) * sizeof(wchar_t));        wn = MultiByteToWideChar(CP_UTF8, 0, line, -1, wline, wn + 1);        wline[wn] = '/0';        size_t usedsiz = wcslen(buf);        while (usedsiz + wn + prefixlen + 4 > bufsiz) {            bufsiz += MAXPATHLEN;            buf = (wchar_t*)PyMem_RawRealloc(buf, (bufsiz + 1) * sizeof(wchar_t));            if (!buf) {                PyMem_RawFree(wline);                goto error;            }        }        if (usedsiz) {            wcscat_s(buf, bufsiz, L";");            usedsiz += 1;        }        errno_t result;        _Py_BEGIN_SUPPRESS_IPH        result = wcscat_s(buf, bufsiz, prefix);        _Py_END_SUPPRESS_IPH        if (result == EINVAL) {            Py_FatalError("invalid argument during ._pth processing");        } else if (result == ERANGE) {            Py_FatalError("buffer overflow during ._pth processing");        }        wchar_t *b = &buf[usedsiz];        join(b, wline);        PyMem_RawFree(wline);    }    module_search_path = buf;    fclose(sp_file);    return 0;error:    PyMem_RawFree(buf);    fclose(sp_file);    return -1;}
开发者ID:cpcloud,项目名称:cpython,代码行数:84,


示例21: wmain

int wmain(int argc, wchar_t *argv[]){  Parameters commandLineParameters;  if (argc < 1)  {    printf("Command line help goes here...");    return 0;  }  CommandLineParser::Parse(argc, argv, &commandLineParameters);  AudioEncoderParameters* encoderParameters = nullptr;  if (commandLineParameters.Quality == 100)  {    encoderParameters = AudioEncoderParameters::CreateLosslessEncoderParameters(2, 44100, 16);  }  else  {    encoderParameters = AudioEncoderParameters::CreateQualityBasedVbrParameters(commandLineParameters.Quality, 2, 44100, 16);  }  // Verify that output folder exists, if specified  // (and add a '/' to it if it doesn't exist)  if (*commandLineParameters.OutputFolder)  {    WIN32_FILE_ATTRIBUTE_DATA fileData;    BOOL success = GetFileAttributesEx(commandLineParameters.OutputFolder, GET_FILEEX_INFO_LEVELS::GetFileExInfoStandard, &fileData);    // check if the file system object exists, but it's not a directory...    if (success && ((fileData.dwFileAttributes & 0x10) == 0))    {      printf("Specified output directory is not a directory");      return 0;    }    if (!success)    {      printf("Specified output directory does not exist");      return 0;    }    size_t outputFolderLength = wcslen(commandLineParameters.OutputFolder);    if (outputFolderLength < MAX_PATH - 1)    {      if (*(commandLineParameters.OutputFolder + outputFolderLength - 1) != '//')      {        *(commandLineParameters.OutputFolder + outputFolderLength) = '//';        *(commandLineParameters.OutputFolder + outputFolderLength + 1) = '/0';      }    }  }  // Initialize COM & Media Foundation  if (!SUCCEEDED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED)))  {    wprintf_s(L"Unable to initialize COM");    return -1;  }  if (!SUCCEEDED(MFStartup(MF_VERSION)))  {    CoUninitialize();    wprintf_s(L"Unable to initialize MediaFoundation");    return -1;  }  try  {    // Use the Windows shell API to extract the path component from the input filename    WCHAR srcFileFolder[MAX_PATH];    WCHAR srcFileName[MAX_PATH];    wcscpy_s(srcFileFolder, commandLineParameters.InputFilename);    BOOL ret = PathRemoveFileSpec(srcFileFolder);    size_t srcFolderLength = wcslen(srcFileFolder);    if (srcFolderLength < MAX_PATH - 1)    {      if (srcFolderLength > 0)      {        if (*(srcFileFolder + srcFolderLength - 1) != '//')        {          *(srcFileFolder + srcFolderLength) = '//';          *(srcFileFolder + srcFolderLength + 1) = '/0';        }      }    }//.........这里部分代码省略.........
开发者ID:bmalec,项目名称:MfEncoder,代码行数:101,


示例22: calculate_path

static voidcalculate_path(void){    wchar_t argv0_path[MAXPATHLEN+1];    wchar_t *buf;    size_t bufsz;    wchar_t *pythonhome = Py_GetPythonHome();    wchar_t *envpath = NULL;    int skiphome, skipdefault;    wchar_t *machinepath = NULL;    wchar_t *userpath = NULL;    wchar_t zip_path[MAXPATHLEN+1];    if (!Py_IgnoreEnvironmentFlag) {        envpath = _wgetenv(L"PYTHONPATH");    }    get_progpath();    /* progpath guaranteed /0 terminated in MAXPATH+1 bytes. */    wcscpy_s(argv0_path, MAXPATHLEN+1, progpath);    reduce(argv0_path);    /* Search for a sys.path file */    {        wchar_t spbuffer[MAXPATHLEN+1];        if ((dllpath[0] && !change_ext(spbuffer, dllpath, L"._pth") && exists(spbuffer)) ||            (progpath[0] && !change_ext(spbuffer, progpath, L"._pth") && exists(spbuffer))) {            if (!read_pth_file(spbuffer, prefix, &Py_IsolatedFlag, &Py_NoSiteFlag)) {                return;            }        }    }    /* Search for an environment configuration file, first in the       executable's directory and then in the parent directory.       If found, open it for use when searching for prefixes.    */    {        wchar_t envbuffer[MAXPATHLEN+1];        wchar_t tmpbuffer[MAXPATHLEN+1];        const wchar_t *env_cfg = L"pyvenv.cfg";        FILE * env_file = NULL;        wcscpy_s(envbuffer, MAXPATHLEN+1, argv0_path);        join(envbuffer, env_cfg);        env_file = _Py_wfopen(envbuffer, L"r");        if (env_file == NULL) {            errno = 0;            reduce(envbuffer);            reduce(envbuffer);            join(envbuffer, env_cfg);            env_file = _Py_wfopen(envbuffer, L"r");            if (env_file == NULL) {                errno = 0;            }        }        if (env_file != NULL) {            /* Look for a 'home' variable and set argv0_path to it, if found */            if (find_env_config_value(env_file, L"home", tmpbuffer)) {                wcscpy_s(argv0_path, MAXPATHLEN+1, tmpbuffer);            }            fclose(env_file);            env_file = NULL;        }    }    /* Calculate zip archive path from DLL or exe path */    change_ext(zip_path, dllpath[0] ? dllpath : progpath, L".zip");    if (pythonhome == NULL || *pythonhome == '/0') {        if (zip_path[0] && exists(zip_path)) {            wcscpy_s(prefix, MAXPATHLEN+1, zip_path);            reduce(prefix);            pythonhome = prefix;        } else if (search_for_prefix(argv0_path, LANDMARK))            pythonhome = prefix;        else            pythonhome = NULL;    }    else        wcscpy_s(prefix, MAXPATHLEN+1, pythonhome);    if (envpath && *envpath == '/0')        envpath = NULL;    skiphome = pythonhome==NULL ? 0 : 1;#ifdef Py_ENABLE_SHARED    machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome);    userpath = getpythonregpath(HKEY_CURRENT_USER, skiphome);#endif    /* We only use the default relative PYTHONPATH if we havent       anything better to use! */    skipdefault = envpath!=NULL || pythonhome!=NULL || /                  machinepath!=NULL || userpath!=NULL;//.........这里部分代码省略.........
开发者ID:cpcloud,项目名称:cpython,代码行数:101,


示例23: MainWndProc

//.........这里部分代码省略.........					// Get the length of the filename without the extension.					int ext_len = wcslen( current_fileinfo->filename );					while ( ext_len != 0 && current_fileinfo->filename[ --ext_len ] != L'.' );					// Select all the text except the file extension (if ext_len = 0, then everything is selected)					SendMessage( g_hWnd_edit, EM_SETSEL, 0, ext_len );					// Allow the edit to proceed.					return FALSE;				}				break;				case LVN_ENDLABELEDIT:				{					NMLVDISPINFO *pdi = ( NMLVDISPINFO * )lParam;					// Prevent the edit if there's no text.					if ( pdi->item.pszText == NULL )					{						return FALSE;					}					// Prevent the edit if the text length is 0.					unsigned int length = wcslen( pdi->item.pszText );					if ( length == 0 )					{						return FALSE;					}					// Free the old filename.					free( current_fileinfo->filename );					// Create a new filename based on the editbox's text.					wchar_t *filename = ( wchar_t * )malloc( sizeof( wchar_t ) * ( length + 1 ) );					wmemset( filename, 0, length + 1 );					wcscpy_s( filename, length + 1, pdi->item.pszText );					// Modify our listview item's fileinfo lParam value.					current_fileinfo->filename = filename;					// Set the image window's new title.					wchar_t new_title[ MAX_PATH + 30 ] = { 0 };					swprintf_s( new_title, MAX_PATH + 30, L"%.259s - %dx%d", filename, gdi_image->GetWidth(), gdi_image->GetHeight() );					SetWindowText( g_hWnd_image, new_title );					return TRUE;				}				break;			}			return FALSE;		}		break;		case WM_DRAWITEM:		{			DRAWITEMSTRUCT *dis = ( DRAWITEMSTRUCT * )lParam;      			// The item we want to draw is our listview.			if ( dis->CtlType == ODT_LISTVIEW && dis->itemData != NULL )			{				fileinfo *fi = ( fileinfo * )dis->itemData;				if ( fi->si == NULL )				{					return TRUE;				}				// Alternate item color's background.
开发者ID:bennyhendra,项目名称:thumbcache-viewer,代码行数:67,


示例24: ZeroMemory

//.........这里部分代码省略.........            os << "Standard Edition";            break;        case PRODUCT_STANDARD_SERVER_CORE:            os << "Standard Edition (core installation)";            break;        case PRODUCT_WEB_SERVER:            os << "Web Server Edition";            break;        }    }    if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)    {        if (GetSystemMetrics(SM_SERVERR2))            os << "Windows Server 2003 R2, ";        else if (osvi.wSuiteMask & VER_SUITE_STORAGE_SERVER)            os << "Windows Storage Server 2003";        else if (osvi.wSuiteMask & VER_SUITE_WH_SERVER)            os << "Windows Home Server";        else if (osvi.wProductType == VER_NT_WORKSTATION &&            si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)        {            os << "Windows XP Professional x64 Edition";        }        else            os << "Windows Server 2003, ";  // Test for the server type.        if (osvi.wProductType != VER_NT_WORKSTATION)        {            if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)            {                if (osvi.wSuiteMask & VER_SUITE_DATACENTER)                    os << "Datacenter Edition for Itanium-based Systems";                else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)                    os << "Enterprise Edition for Itanium-based Systems";            }            else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)            {                if (osvi.wSuiteMask & VER_SUITE_DATACENTER)                    os << "Datacenter x64 Edition";                else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)                    os << "Enterprise x64 Edition";                else                    os << "Standard x64 Edition";            }            else            {                if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER)                    os << "Compute Cluster Edition";                else if (osvi.wSuiteMask & VER_SUITE_DATACENTER)                    os << "Datacenter Edition";                else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)                    os << "Enterprise Edition";                else if (osvi.wSuiteMask & VER_SUITE_BLADE)                    os << "Web Edition";                else                    os << "Standard Edition";            }        }    }    if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)    {        os << "Windows XP ";        if (osvi.wSuiteMask & VER_SUITE_PERSONAL)            os << "Home Edition";        else            os << "Professional";    }    if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)    {        os << "Windows 2000 ";  if (osvi.wProductType == VER_NT_WORKSTATION)        {            os << "Professional";        }        else        {            if (osvi.wSuiteMask & VER_SUITE_DATACENTER)                os << "Datacenter Server";            else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)                os << "Advanced Server";            else                os << "Server";        }    }    // Include service pack (if any) and build number.    if (wcslen(osvi.szCSDVersion) > 0) {        os << " " << osvi.szCSDVersion;    }    os << L" (build " << osvi.dwBuildNumber << L")"; if (osvi.dwMajorVersion >= 6) {        if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)            os << ", 64-bit";        else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)            os << ", 32-bit";    }    wcscpy_s(str, bufferSize, os.str().c_str());    // convert wchar* to string    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;    std::string narrow = converter.to_bytes(str);    delete str;    return narrow;}
开发者ID:newton449,项目名称:virtual-server,代码行数:101,


示例25: wmain

//.........这里部分代码省略.........					{						payload_settings.TRANSPORT = L"METERPRETER_TRANSPORT_HTTPS";					}					else if (wcscmp(payload_settings.TRANSPORT,L"BIND_TCP") == 0)					{						payload_settings.TRANSPORT = L"METERPRETER_TRANSPORT_SSL";						bBind = true;					}					else if (wcscmp(payload_settings.TRANSPORT,L"BIND_METSVC") == 0)					{						payload_settings.TRANSPORT = L"METERPRETER_TRANSPORT_SSL";						metsvc = true;						bBind = true;					}					else {						dprintf(L"[-] Unknown transport: /"%s/"/n[-] Valid transports are reverse_tcp, reverse_metsvc, reverse_http,", payload_settings.TRANSPORT);						dprintf(L"/n    reverse_https, bind_tcp and bind_metsvc./n");  						exit(1);					}					// End of Transport checks				} else if (wcscmp(argv[i], L"-h") == 0) {		//LHOST					payload_settings.LHOST = argv[i + 1];				} else if (wcscmp(argv[i], L"-p") == 0) {		//LPORT					payload_settings.LPORT = argv[i + 1];				} else if (wcscmp(argv[i], L"-ct") == 0) {		//SessionCommunicationTimeout in seconds - 300 by default					payload_settings.comm_timeout = _wtoi(argv[i + 1]);				} else if (wcscmp(argv[i], L"-et") == 0) {		//SessionExpirationTimeout in seconds - 604800 by default					payload_settings.expiration_timeout = _wtoi(argv[i + 1]);				}  else if (wcscmp(argv[i], L"-ua") == 0) {		//USER_AGENT					payload_settings.USER_AGENT = argv[i + 1];				}  else if (wcscmp(argv[i], L"-f") == 0) {		//Should we load the stage from a file rather than from the resource?					wcscpy_s(StageFilePath,argv[i + 1]);				}  else if (wcscmp(argv[i], L"--help") == 0) {		//Print usage and quit					print_header();					usage();					exit(1);				}  else if (wcscmp(argv[i], L"--msfpayload") == 0) {		//are we going to mimic msfpayload?					MSFPAYLOAD = true;				}		}		//Do we have the minimum parameters?		if(payload_settings.TRANSPORT == NULL || payload_settings.LPORT == NULL || payload_settings.LHOST == NULL)		{			dprintf(L"[-] Not enough parameters! /n/n");			usage();			exit(1);		} else validTransport = false; // This is a bit confusing, but works: if we have the minimum info to get started, we will set validTransport to false so we will not start parsing options from resource.				//////////////////////// start of msfpayload //////////////////////////////		if(MSFPAYLOAD) // We will create a new exe with specified options, then exit		{			dprintf(L"[*] Switching to MSFPAYLOAD mode, parsing options ... /n");			dprintf(L"/tTRANSPORT/t:/t%s/n",UNICODEtransport_2);			dprintf(L"/tLHOST/t/t:/t%s/n",payload_settings.LHOST);			dprintf(L"/tLPORT/t/t:/t%s/n",payload_settings.LPORT);			UnicodeToAnsi(ANSItransport, UNICODEtransport_2);			UnicodeToAnsi(ANSIlhost, payload_settings.LHOST);			UnicodeToAnsi(ANSIlport, payload_settings.LPORT);			msfpayload(ANSItransport, ANSIlhost, ANSIlport);			//msfpayload will exit ...		}
开发者ID:BaldyBadgersRunningRoundMyBrain,项目名称:inmet,代码行数:66,


示例26: wstring

HWND TabView::CreateNewConsole(ConsoleViewCreate* consoleViewCreate, const wstring& strCmdLineInitialDir /*= wstring(L"")*/, const wstring& strCmdLineInitialCmd /*= wstring(L"")*/, DWORD dwBasePriority /*= ULONG_MAX*/){	DWORD dwRows    = g_settingsHandler->GetConsoleSettings().dwRows;	DWORD dwColumns = g_settingsHandler->GetConsoleSettings().dwColumns;	MutexLock	viewMapLock(m_viewsMutex);#if 0	if (m_views.size() > 0)	{		SharedMemory<ConsoleParams>& consoleParams = m_views.begin()->second->GetConsoleHandler().GetConsoleParams();		dwRows		= consoleParams->dwRows;		dwColumns	= consoleParams->dwColumns;	}	else	{		// initialize member variables for the first view		m_dwRows	= dwRows;		m_dwColumns	= dwColumns;	}#endif	std::shared_ptr<ConsoleView> consoleView(new ConsoleView(m_mainFrame, m_hWnd, m_tabData, dwRows, dwColumns, strCmdLineInitialDir, strCmdLineInitialCmd, dwBasePriority));	consoleView->Group(this->IsGrouped());	UserCredentials userCredentials;	if( consoleViewCreate->type == ConsoleViewCreate::CREATE )	{		consoleViewCreate->u.userCredentials = &userCredentials;		if (m_tabData->bRunAsUser)		{			userCredentials.netOnly = m_tabData->bNetOnly;#ifdef _USE_AERO			// Display a dialog box to request credentials.			CREDUI_INFO ui;			ui.cbSize = sizeof(ui);			ui.hwndParent = m_hWnd;			ui.pszMessageText = m_tabData->strShell.c_str();			ui.pszCaptionText = L"Run as different user";			ui.hbmBanner = NULL;			// we need a target			WCHAR szModuleFileName[_MAX_PATH] = L"";			::GetModuleFileName(NULL, szModuleFileName, ARRAYSIZE(szModuleFileName));			WCHAR szUser    [CREDUI_MAX_USERNAME_LENGTH + 1] = L"";			WCHAR szPassword[CREDUI_MAX_PASSWORD_LENGTH + 1] = L"";			wcscpy_s(szUser, ARRAYSIZE(szUser), m_tabData->strUser.c_str());			try			{				if (g_settingsHandler->GetBehaviorSettings2().runAsUserSettings.bUseCredentialProviders)				{					ULONG ulAuthPackage = 0;					std::unique_ptr<BYTE[]> pvInAuthBlob;					ULONG cbInAuthBlob  = 0;					std::unique_ptr<void, CoTaskMemFreeHelper> pvOutAuthBlob;					ULONG cbOutAuthBlob = 0;					BOOL  fSave         = FALSE;					if( szUser[0] )					{						::CredPackAuthenticationBuffer(							0,                                //_In_     DWORD dwFlags,							szUser,                           //_In_     LPTSTR pszUserName,							szPassword,                       //_In_     LPTSTR pszPassword,							nullptr,                          //_Out_    PBYTE pPackedCredentials,							&cbInAuthBlob                     //_Inout_  DWORD *pcbPackedCredentials							);						pvInAuthBlob.reset(new BYTE [cbInAuthBlob]);						if( !::CredPackAuthenticationBuffer(							0,                                //_In_     DWORD dwFlags,							szUser,                           //_In_     LPTSTR pszUserName,							szPassword,                       //_In_     LPTSTR pszPassword,							pvInAuthBlob.get(),               //_Out_    PBYTE pPackedCredentials,							&cbInAuthBlob                     //_Inout_  DWORD *pcbPackedCredentials							) )							Win32Exception::ThrowFromLastError("CredPackAuthenticationBuffer");					}					{						PVOID pvAuthBlob = nullptr;						DWORD rc = ::CredUIPromptForWindowsCredentials(							&ui,                              //_In_opt_     PCREDUI_INFO pUiInfo,							0,                                //_In_         DWORD dwAuthError,							&ulAuthPackage,                   //_Inout_      ULONG *pulAuthPackage,							pvInAuthBlob.get(),               //_In_opt_     LPCVOID pvInAuthBuffer,							cbInAuthBlob,                     //_In_         ULONG ulInAuthBufferSize,							&pvAuthBlob,                      //_Out_        LPVOID *ppvOutAuthBuffer,							&cbOutAuthBlob,                   //_Out_        ULONG *pulOutAuthBufferSize,							&fSave,                           //_Inout_opt_  BOOL *pfSave,							pvInAuthBlob.get()                //_In_         DWORD dwFlags							? CREDUIWIN_IN_CRED_ONLY							: 0							);						if( rc == ERROR_CANCELLED )							return 0;//.........这里部分代码省略.........
开发者ID:gadiyar,项目名称:console,代码行数:101,


示例27: TrueSetupDiGetDeviceInstanceIdW

BOOL WINAPI HookSA::HookSetupDiGetDeviceInstanceIdW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PWSTR DeviceInstanceId, DWORD DeviceInstanceIdSize, PDWORD RequiredSize){	BOOL ret = TrueSetupDiGetDeviceInstanceIdW(DeviceInfoSet, DeviceInfoData, DeviceInstanceId, DeviceInstanceIdSize, RequiredSize);	if (!InputHookManager::Get().GetInputHook().GetState(InputHook::HOOK_SA)) return ret;	PrintLog("SetupDiGetDeviceInstanceId");	if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) return ret;	InputHookManager::Get().GetInputHook().StartTimeoutThread();	if (DeviceInstanceId && ret)	{		DWORD dwPid = 0, dwVid = 0;		wchar_t* strVid = wcsstr(DeviceInstanceId, L"VID_");		if (!strVid || swscanf_s(strVid, L"VID_%4X", &dwVid) < 1)			return ret;		wchar_t* strPid = wcsstr(DeviceInstanceId, L"PID_");		if (!strPid || swscanf_s(strPid, L"PID_%4X", &dwPid) < 1)			return ret;		for (auto padcfg = InputHookManager::Get().GetInputHook().begin(); padcfg != InputHookManager::Get().GetInputHook().end(); ++padcfg)		{			if (padcfg->GetProductPIDVID() == (DWORD)MAKELONG(dwVid, dwPid))			{				const wchar_t* strUSB = wcsstr(DeviceInstanceId, L"USB//");				const wchar_t* strRoot = wcsstr(DeviceInstanceId, L"root//");				DWORD dwHookVid = InputHookManager::Get().GetInputHook().GetState(InputHook::HOOK_PIDVID) ? LOWORD(InputHookManager::Get().GetInputHook().GetFakePIDVID()) : LOWORD(padcfg->GetProductPIDVID());				DWORD dwHookPid = InputHookManager::Get().GetInputHook().GetState(InputHook::HOOK_PIDVID) ? HIWORD(InputHookManager::Get().GetInputHook().GetFakePIDVID()) : HIWORD(padcfg->GetProductPIDVID());				std::wstring tmpString;				if (strUSB || strRoot)				{					const wchar_t* p = wcsrchr(DeviceInstanceId, L'//');					if (p) tmpString = StringFormat(L"USB//VID_%04X&PID_%04X&IG_%02d%s", dwHookVid, dwHookPid, padcfg->GetUserIndex(), p);					else tmpString = StringFormat(L"USB//VID_%04X&PID_%04X&IG_%02d", dwHookVid, dwHookPid, padcfg->GetUserIndex());					if (DeviceInstanceIdSize < tmpString.size())					{						SetLastError(ERROR_INSUFFICIENT_BUFFER);						if (RequiredSize) *RequiredSize = (DWORD)tmpString.size() + 1;						//return FALSE; //NOTE: return FALSE here breaks Beat Hazard						continue;					}					else if (DeviceInstanceIdSize > tmpString.size())					{						PrintLog("Device string change:", DeviceInstanceId);						PrintLog("%ls", DeviceInstanceId);						wcscpy_s(DeviceInstanceId, DeviceInstanceIdSize, tmpString.c_str());						if (RequiredSize) *RequiredSize = (DWORD)tmpString.size() + 1;						PrintLog("%ls", DeviceInstanceId);						continue;					}				}				wchar_t* strHID = wcsstr(DeviceInstanceId, L"HID//");				if (strHID)				{					wchar_t* p = wcsrchr(DeviceInstanceId, L'//');					tmpString = StringFormat(L"HID//VID_%04X&PID_%04X&IG_%02d%s", dwHookVid, dwHookPid, padcfg->GetUserIndex(), p);					if (DeviceInstanceIdSize < tmpString.size())					{						SetLastError(ERROR_INSUFFICIENT_BUFFER);						if (RequiredSize) *RequiredSize = (DWORD)tmpString.size() + 1;						//return FALSE; //NOTE: return FALSE here breaks Beat Hazard						continue;					}					else if (DeviceInstanceIdSize > tmpString.size())					{						PrintLog("Device string change:", DeviceInstanceId);						PrintLog("%ls", DeviceInstanceId);						wcscpy_s(DeviceInstanceId, DeviceInstanceIdSize, tmpString.c_str());						if (RequiredSize) *RequiredSize = (DWORD)tmpString.size() + 1;						PrintLog("%ls", DeviceInstanceId);						continue;					}				}			}		}	}	return ret;}
开发者ID:FantomKnight,项目名称:nucleuscoop,代码行数:87,


示例28: DeviceConfigure

//.........这里部分代码省略.........    //    status = WdfDeviceOpenRegistryKey(                            device,                            PLUGPLAY_REGKEY_DEVICE,                            KEY_QUERY_VALUE,                            WDF_NO_OBJECT_ATTRIBUTES,                            &key);    if (!NT_SUCCESS(status)) {        Trace(TRACE_LEVEL_ERROR,            "Error: Failed to retrieve device hardware key root");        goto Exit;    }    status = WdfRegistryQueryUnicodeString(                            key,                            &portName,                            NULL,                            &comPort);    if (!NT_SUCCESS(status)) {        Trace(TRACE_LEVEL_ERROR,            "Error: Failed to read PortName");        goto Exit;    }            //    // Manually create the symbolic link name. Length is the length in    // bytes not including the NULL terminator.    //    // 6054 and 26035 are code analysis warnings that comPort.Buffer might    // not be NULL terminated, while we know that they are.     //    #pragma warning(suppress: 6054 26035)    symbolicLinkName.Length = (USHORT)((wcslen(comPort.Buffer) * sizeof(wchar_t))                                + sizeof(SYMBOLIC_LINK_NAME_PREFIX) - sizeof(UNICODE_NULL));                                    if (symbolicLinkName.Length >= symbolicLinkName.MaximumLength) {                Trace(TRACE_LEVEL_ERROR, "Error: Buffer overflow when creating COM port name. Size"            " is %d, buffer length is %d", symbolicLinkName.Length, symbolicLinkName.MaximumLength);        status = STATUS_BUFFER_OVERFLOW;        goto Exit;    }            errorNo = wcscpy_s(symbolicLinkName.Buffer,                       SYMBOLIC_LINK_NAME_LENGTH,                       SYMBOLIC_LINK_NAME_PREFIX);                               if (errorNo != 0) {        Trace(TRACE_LEVEL_ERROR,               "Failed to copy %ws to buffer with error %d",              SYMBOLIC_LINK_NAME_PREFIX, errorNo);        status = STATUS_INVALID_PARAMETER;        goto Exit;    }            errorNo = wcscat_s(symbolicLinkName.Buffer,                       SYMBOLIC_LINK_NAME_LENGTH,                       comPort.Buffer);                               if (errorNo != 0) {        Trace(TRACE_LEVEL_ERROR,               "Failed to copy %ws to buffer with error %d",              comPort.Buffer, errorNo);        status = STATUS_INVALID_PARAMETER;        goto Exit;    }                                    //    // Create symbolic link    //    status = WdfDeviceCreateSymbolicLink(                            device,                            &symbolicLinkName);    if (!NT_SUCCESS(status)) {        Trace(TRACE_LEVEL_ERROR,            "Error: Cannot create symbolic link %ws", symbolicLinkName.Buffer);        goto Exit;    }    status = DeviceGetPdoName(DeviceContext);    if (!NT_SUCCESS(status)) {        goto Exit;    }    status = DeviceWriteLegacyHardwareKey(                            DeviceContext->PdoName,                            comPort.Buffer,                            DeviceContext->Device);    if (NT_SUCCESS(status)) {        DeviceContext->CreatedLegacyHardwareKey = TRUE;    }    status = QueueCreate(DeviceContext);    if (!NT_SUCCESS(status)) {        goto Exit;    }Exit:    return status;}
开发者ID:0xhack,项目名称:Windows-driver-samples,代码行数:101,


示例29: CordbCommonBase

// ConstructorCorpubProcess::CorpubProcess(DWORD dwProcessId,                             bool fManaged,                             HANDLE hProcess,                             HANDLE hMutex,                             AppDomainEnumerationIPCBlock *pAD,#if !defined(FEATURE_DBGIPC_TRANSPORT_DI)                             IPCReaderInterface *pIPCReader,#endif // !FEATURE_DBGIPC_TRANSPORT_DI                             FPGetModuleFileNameEx * fpGetModuleFileNameEx)    : CordbCommonBase(0, enumCorpubProcess),      m_dwProcessId(dwProcessId),      m_fIsManaged(fManaged),      m_hProcess(hProcess),      m_hMutex(hMutex),      m_AppDomainCB(pAD),#if !defined(FEATURE_DBGIPC_TRANSPORT_DI)      m_pIPCReader(pIPCReader),#endif // !FEATURE_DBGIPC_TRANSPORT_DI      m_pNext(NULL){    {        // First try to get the process name from the OS. That can't be spoofed by badly formed IPC block.        // psapi!GetModuleFileNameExW can get that, but it's not available on all platforms so we        // need to load it dynamically.        if (fpGetModuleFileNameEx != NULL)        {            // MSDN is very confused about whether the lenght is in bytes (MSDN 2002) or chars (MSDN 2004).            // We err on the safe side by having buffer that's twice as large, and ignoring            // the units on the return value.            WCHAR szName[MAX_PATH * sizeof(WCHAR)];            DWORD lenInCharsOrBytes = MAX_PATH*sizeof(WCHAR);            // Pass NULL module handle to get "Main Module", which will give us the process name.            DWORD ret = (*fpGetModuleFileNameEx) (hProcess, NULL, szName, lenInCharsOrBytes);            if (ret > 0)            {                // Recompute string length because we don't know if 'ret' is in bytes or char.                SIZE_T len = wcslen(szName) + 1;                m_szProcessName = new (nothrow) WCHAR[len];                if (m_szProcessName != NULL)                {                    wcscpy_s(m_szProcessName, len, szName);                    goto exit;                }            }        }        // This is a security feature on WinXp + above, so make sure it worked there.        CONSISTENCY_CHECK_MSGF(FALSE, ("On XP/2k03 OSes + above, we should have been able to get/n"            "the module name from psapi!GetModuleFileNameEx. fp=0x%p/n.", fpGetModuleFileNameEx));    }    // We couldn't get it from the OS, so fallthrough to getting it from the IPC block.    // Fetch the process name from the AppDomainIPCBlock    _ASSERTE (pAD->m_szProcessName != NULL);    if (pAD->m_szProcessName == NULL)        m_szProcessName = NULL;    else    {        SIZE_T nBytesRead;        _ASSERTE(pAD->m_iProcessNameLengthInBytes > 0);        // Note: this assumes we're reading the null terminator from        // the IPC block.        m_szProcessName = (WCHAR*) new (nothrow) char[pAD->m_iProcessNameLengthInBytes];        if (m_szProcessName == NULL)        {            LOG((LF_CORDB, LL_INFO1000,             "CP::CP: Failed to allocate memory for ProcessName./n"));            goto exit;        }        BOOL bSucc = ReadProcessMemory(hProcess,                                        pAD->m_szProcessName,                                        m_szProcessName,                                        pAD->m_iProcessNameLengthInBytes,                                        &nBytesRead);        if ((bSucc == 0) ||            (nBytesRead != (SIZE_T)pAD->m_iProcessNameLengthInBytes))        {            // The EE may have done a rude exit            LOG((LF_CORDB, LL_INFO1000,             "CP::EAD: ReadProcessMemory (ProcessName) failed./n"));        }    }exit:    ;}
开发者ID:Afshintm,项目名称:coreclr,代码行数:96,


示例30: NSudoDlgCallBack

INT_PTR CALLBACK NSudoDlgCallBack(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){	HWND hUserName = GetDlgItem(hDlg, IDC_UserName);	HWND hTokenPrivilege = GetDlgItem(hDlg, IDC_TokenPrivilege);	HWND hMandatoryLabel = GetDlgItem(hDlg, IDC_MandatoryLabel);	HWND hszPath = GetDlgItem(hDlg, IDC_szPath);	wchar_t szCMDLine[260], szUser[260], szPrivilege[260], szMandatory[260], szBuffer[260];	switch (message)	{	case WM_INITDIALOG:				// Show NSudo Logo		SendMessageW(			GetDlgItem(hDlg, IDC_NSudoLogo),			STM_SETIMAGE,			IMAGE_ICON,			LPARAM(LoadImageW(GetModuleHandleW(NULL), MAKEINTRESOURCE(IDI_NSUDO), IMAGE_ICON, 0, 0, LR_COPYFROMRESOURCE)));		//Show Warning Icon		SendMessageW(			GetDlgItem(hDlg, IDC_Icon),			STM_SETIMAGE,			IMAGE_ICON,			LPARAM(LoadIconW(NULL, IDI_WARNING)));		SendMessageW(hUserName, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_TI);		SendMessageW(hUserName, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_Sys);		SendMessageW(hUserName, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_CP);		SendMessageW(hUserName, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_CU);		SendMessageW(hUserName, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_CPD);		SendMessageW(hUserName, CB_SETCURSEL, 4, 0); //设置默认项"TrustedInstaller"				SendMessageW(hTokenPrivilege, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_Default);		SendMessageW(hTokenPrivilege, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_EnableAll);		SendMessageW(hTokenPrivilege, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_DisableAll);		SendMessageW(hTokenPrivilege, CB_SETCURSEL, 2, 0); //设置默认项"默认"		SendMessageW(hMandatoryLabel, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_Low);		SendMessageW(hMandatoryLabel, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_Medium);		SendMessageW(hMandatoryLabel, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_High);		SendMessageW(hMandatoryLabel, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_System);		SendMessageW(hMandatoryLabel, CB_INSERTSTRING, 0, (LPARAM)TextRes.NSudo_Text_Default);		SendMessageW(hMandatoryLabel, CB_SETCURSEL, 0, 0); //设置默认项"默认"		{			wchar_t szItem[260], szBuffer[32768];			DWORD dwLength = GetPrivateProfileSectionNamesW(szBuffer, 32768, szShortCutListPath);			for (DWORD i = 0, j = 0; i < dwLength; i++,j++)			{				if (szBuffer[i] != NULL)				{					szItem[j] = szBuffer[i];				}				else				{					szItem[j] = NULL;					SendMessageW(hszPath, CB_INSERTSTRING, 0, (LPARAM)szItem);					j=-1;				}			}		}		return (INT_PTR)TRUE;	case WM_COMMAND:		switch (LOWORD(wParam))		{		case IDC_Run:			GetDlgItemTextW(hDlg, IDC_UserName, szUser, sizeof(szUser));			GetDlgItemTextW(hDlg, IDC_TokenPrivilege, szPrivilege, sizeof(szPrivilege));			GetDlgItemTextW(hDlg, IDC_MandatoryLabel, szMandatory, sizeof(szMandatory));			GetDlgItemTextW(hDlg, IDC_szPath, szCMDLine, sizeof(szCMDLine));			NSudo_Run(hDlg,szUser, szPrivilege, szMandatory, szCMDLine);			break;		case IDC_About:			NSudoReturnMessage(TextRes.NSudo_AboutText);			break;		case IDC_Browse:			wcscpy_s(szBuffer, 260, L"");			NSudoBrowseDialog(hDlg, szBuffer);			SetDlgItemTextW(hDlg, IDC_szPath, szBuffer);			break;		}		break;	case WM_SYSCOMMAND:		switch (LOWORD(wParam))		{		case SC_CLOSE:			PostQuitMessage(0);			break;		}		break;	}	return 0;}
开发者ID:azraelrabbit,项目名称:NSudo,代码行数:98,



注:本文中的wcscpy_s函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ wcsdup函数代码示例
C++ wcscpy_c函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。