Exemplo n.º 1
0
BOOL AddURLToDownload (LPCSTR pszUrl, LPCSTR pszReferer, LPCSTR pszComment, BOOL bAutoStart)
{
	DWORD dwErr;
	HKEY key;
	static int _iKey = 0;

	char szKey [1000];
	wsprintf (szKey, "URLsToDownload\\FdmSetupInstaller_%d", _iKey++);

	dwErr = RegCreateKey (_hFDMKey, szKey, &key);

	if (dwErr != ERROR_SUCCESS && dwErr)
		return FALSE;

	RegSetValueEx (key, "URL", NULL, REG_SZ, LPBYTE (pszUrl), lstrlen (pszUrl));
	RegSetValueEx (key, "Referer", NULL, REG_SZ, LPBYTE (pszReferer), lstrlen (pszReferer));
	RegSetValueEx (key, "Comment", NULL, REG_SZ, LPBYTE (pszComment), lstrlen (pszComment));
	DWORD dw = TRUE;
	RegSetValueEx (key, "Silent", NULL, REG_DWORD, (LPBYTE)&dw, sizeof (dw));
	RegSetValueEx (key, "zlr", 0, REG_DWORD, (LPBYTE)&dw, sizeof (dw));
	
	if (bAutoStart)
		dw = TRUE;
	else
		dw = FALSE;

	RegSetValueEx (key, "AutoStart", NULL, REG_DWORD, (LPBYTE)&dw, sizeof (dw));
	
	RegCloseKey (key);

	return TRUE;
}
Exemplo n.º 2
0
void CClientContext::OnRecvDataCompleted( DWORD dwIOSize )
{		
	CString strLog;
	ASSERT(m_cRecvDataBuffer != NULL);

	m_dwReceivedSize += dwIOSize;
	m_i64RecvCnt++;
	strLog.Format(_T("GTM:[1]m_dwPacketSize=%d,m_dwReceivedSize=%d,dwIOSize=%d,"),m_dwPacketSize,m_dwReceivedSize,dwIOSize);
	//OutputDebugString(strLog);
	//printf("recv[%x]_%I64d,iosize=%d---total=%d\r\n",this,m_i64RecvCnt,dwIOSize,m_dwReceivedSize);

	char * pData = m_iIO.databuf.buf;
	pData[dwIOSize] = '\0';
	//strLog.Format()
// 	if (m_dwReceivedSize < m_dwPacketSize)
// 	{				
// 		AsyncRecvBody(m_dwPacketSize - m_dwReceivedSize);
// 	}
// 	else if (m_dwReceivedSize == m_dwPacketSize)
	{			
		strLog.Format(_T("GTM:[2]m_dwPacketSize=%d,m_dwReceivedSize=%d,dwIOSize=%d"),m_dwPacketSize,m_dwReceivedSize,dwIOSize);
		//OutputDebugString(strLog);

		strLog.Format(_T("Server have received a msg(%d).Socket=%d. OnRecvBodyCompleted"),m_dwPacketSize,m_s);
		//WriteLog(SERVERLOGNAME, _T("OnRecvBodyCompleted"), strLog);

		if (m_pRecvCBFunc != NULL)
		{
			m_pRecvCBFunc(STATUS_OK,LPBYTE(this), LPBYTE(pData), dwIOSize, m_pRecvCBUserData);
		}
		else
		{
			WriteLog(SERVERLOGNAME, logLevelWarring, _T("m_pRecvCBFunc == NULL when OnRecvBodyCompleted!"));
		}

		//必须也用m_CallBackLock保护,防止在析构里同时释放内存池
// 		if(!m_pMemPool->ReleaseBuffer(m_pRecvBufferCell,1))
// 		{
// 			strLog.Format(_T("m_pMemPool->ReleaseBuffer failed. Socket=%d"), m_s);
// 			WriteLog(SERVERLOGNAME,logLevelWarring, strLog);
// 		}
// 		m_pRecvBufferCell = NULL;

		AsyncRecvData();
	}
// 	else
// 	{
// 		strLog.Format(_T("GTM:[3]m_dwPacketSize=%d,m_dwReceivedSize=%d,dwIOSize=%d"),m_dwPacketSize,m_dwReceivedSize,dwIOSize);
// 		//OutputDebugString(strLog);
// 	}
}
Exemplo n.º 3
0
void* CCrypt::decodeBuffer(const BYTE *pBuf, size_t bufLen, size_t *cbResultLen)
{
	if (cbResultLen)
		*cbResultLen = 0;

	if (!m_valid || pBuf == NULL || (bufLen % BLOCK_SIZE) != 0)
		return NULL;

	char *result = (char*)mir_alloc(bufLen + 1);

	if (decrypt_cbc(m_ctx, LPBYTE(pBuf), (BYTE*)result, bufLen)) {
		mir_free(result);
		return NULL;
	}

	result[bufLen] = 0;
	WORD cbLen = *(PWORD)result;
	if (cbLen > bufLen) {
		mir_free(result);
		return NULL;
	}

	memmove(result, result + 2, cbLen);
	if (cbResultLen)
		*cbResultLen = cbLen;
	return result;
}
Exemplo n.º 4
0
bool
CExampleDlg::SaveSetting(HKEY key, LPCTSTR pcName, LPCTSTR pcValue)
{
	DWORD nBytes = DWORD(sizeof(TCHAR) * (_tcslen(pcValue) + 1));
	return RegSetValueEx(key, pcName, 0, REG_SZ, LPBYTE(pcValue),
			nBytes) == ERROR_SUCCESS;
}
Exemplo n.º 5
0
bool
CExampleDlg::LoadSetting(HKEY key, LPCTSTR pcName, LPTSTR pcValue,
		DWORD nValueSize)
{
	return RegQueryValueEx(key, pcName, 0, 0, LPBYTE(pcValue),
			&nValueSize) == ERROR_SUCCESS;
}
//--------------------------------------------------------------------------------
CNTService::~CNTService()
	{
	AFX_MANAGE_STATE_IF_DLL

	g_this = NULL;
	delete[] LPBYTE(m_pUserSID);
	}
Exemplo n.º 7
0
HRESULT CLZMA::ReadPart(void *data, UINT32 size, UINT32 *processedSize)
{
  if (processedSize)
    *processedSize = 0;
  while (size)
  {
    if (!avail_in)
    {
      if (finish)
      {
        return S_OK;
      }
      GetMoreIO();
      if (!avail_in)
      {
        if (finish)
        {
          return S_OK;
        }
        return E_ABORT;
      }
      if (compressor_finished)
        return E_ABORT;
    }
    UINT32 l = std::min(size, avail_in);
    memcpy(data, next_in, l);
    avail_in -= l;
    size -= l;
    next_in += l;
    data = LPBYTE(data) + l;
    if (processedSize)
      *processedSize += l;
  }
  return S_OK;
}
Exemplo n.º 8
0
bool pws_os::RegReadSTValue(const TCHAR *name, stringT &value)
{
  if (!bSubTreeKeyValid)
    return bSubTreeKeyValid;

  bool retval = false;
  LONG rv;
  DWORD dwType, DataLen;
  rv = ::RegQueryValueEx(hSubTreeKey,
                         name,
                         NULL,
                         &dwType,
                         NULL,
                         &DataLen);
  if (rv == ERROR_SUCCESS && dwType == REG_SZ) {
    DataLen++;
    TCHAR *pData = new TCHAR[DataLen];
    ::memset(pData, 0, DataLen);
    rv = ::RegQueryValueEx(hSubTreeKey,
                            name,
                            NULL,
                            &dwType,
                            LPBYTE(pData),
                            &DataLen);

    if (rv == ERROR_SUCCESS) {
      value = pData;
      retval = true;
    }
    delete[] pData;
  }
  return retval;
}
Exemplo n.º 9
0
QPCSCReader::Result QPCSCReader::transfer( const QByteArray &cmd ) const
{
	static const SCARD_IO_REQUEST T0 = { 1, 8 };
	static const SCARD_IO_REQUEST T1 = { 2, 8 };
	QByteArray data( 255 + 3, 0 );
	DWORD size = data.size();

	qDebug() << "Send:" << cmd.toHex();
	DWORD ret = SCardTransmit( d->card, d->proto == SCARD_PROTOCOL_T0 ? &T0 : &T1,
		LPCBYTE(cmd.constData()), cmd.size(), 0, LPBYTE(data.data()), &size );
	if( ret != SCARD_S_SUCCESS )
	{
		qDebug() << "Err:" << ret;
		return Result();
	}

	Result result( data.mid( size-2, 2 ), data.left( size - 2 ) );
	qDebug() << "Recv:" << result.first.toHex() << result.second.toHex();

	if( result.first.at( 0 ) == 0x61 )
	{
		QByteArray cmd( "\x00\xC0\x00\x00\x00", 5 );
		cmd[4] = data.at( size-1 );
		return transfer( cmd );
	}
	return result;
}
Exemplo n.º 10
0
int CTimeoutSocket::Receive(void *lpBuf, int nBufLen, DWORD uTimeout, int nFlags)
{
	int nResult = _Receive(lpBuf, nBufLen, uTimeout, nFlags);

	if (nResult > 0 && nResult < nBufLen && m_nRecvRetry > 0)
	{// 收到数据但是没有达到目标数量

		int nRecvRetry = m_nRecvRetry;
		LPBYTE pBuff = LPBYTE(lpBuf);
		pBuff += nResult;
		nBufLen -= nResult;
		--nRecvRetry;
		int nRecv = _Receive(lpBuf, nBufLen, m_uRecvCrackTimeout, nFlags);
		while(nRecv > 0)
		{
			nResult += nRecv;
			pBuff += nRecv;
			nBufLen -= nRecv;
			if (nBufLen < 1 || nRecvRetry < 1)
				break;
			nRecv = _Receive(lpBuf, nBufLen, m_uRecvCrackTimeout, nFlags);
		}
	}

	return nResult;
}
Exemplo n.º 11
0
HGLOBAL POTraceCtl::CreateDropFilesW(const String& strUrl)
{
	int nBufferSize = sizeof(DROPFILES) + sizeof(wchar) * (strUrl.GetLength() + 1) + sizeof(wchar);

	// Allocate memory from the heap for the DROPFILES struct.
	HGLOBAL hgDrop = GlobalAlloc( GHND | GMEM_SHARE, nBufferSize);
	if( NULL == hgDrop )
		return 0;
	
	DROPFILES* pDrop = (DROPFILES*) GlobalLock(hgDrop);
	if( NULL == pDrop )
	{
		GlobalFree(hgDrop);
		return 0;
	}

	pDrop->pFiles = sizeof(DROPFILES);
	pDrop->fWide = TRUE;

	wchar* pszBuff = (wchar*) (LPBYTE(pDrop) + sizeof(DROPFILES));
	chustd::Memory::Copy16(pszBuff, strUrl.GetBuffer(), strUrl.GetLength() + 1);
	
	GlobalUnlock(hgDrop);

	return hgDrop;
}
Exemplo n.º 12
0
	// ////////////////////////////////////////////////////////////////////////////////
	// @private IsClassNet 
	//
	static BOOL IsClassNet( GUID * ClassGuid )
	{
#define MAX_NUM  50

		HKEY hKeyClass;
		LONG lRet;
		WCHAR ClassType[MAX_NUM];
		WCHAR NetClass[MAX_NUM] = L"Net";
		DWORD dwLength = MAX_NUM,dwType = REG_SZ;

		if (hKeyClass = SetupDiOpenClassRegKey(ClassGuid,KEY_READ))
		{
			lRet = RegQueryValueExW(
				hKeyClass, 
				L"Class", 
				NULL, 
				&dwType, 
				LPBYTE(ClassType), 
				&dwLength);

			RegCloseKey(hKeyClass);

			if ( lRet != ERROR_SUCCESS )
			{
				return FALSE;
			}

			if ( !wcscmp(ClassType,NetClass) )
			{
				return TRUE;
			}
		}                                 

		return FALSE;
	}
Exemplo n.º 13
0
CHtmlStream& CHtmlStream::operator<<(const CLongBinary& blob)
{
	if (blob.m_dwDataLength > 0 && blob.m_hData != NULL)
	{
		LPBYTE pbData = LPBYTE( GlobalLock(blob.m_hData) );
	  if (pbData != NULL )
	  {
		 UINT_PTR nBytesLeft;

		 nBytesLeft = blob.m_dwDataLength;
		 while( nBytesLeft > 0 )
		 {
			UINT nBytesToWrite;

			nBytesToWrite = (UINT)min( nBytesLeft, INT_MAX );
			Write(pbData, nBytesToWrite);
			nBytesLeft -= nBytesToWrite;
			pbData += nBytesToWrite;
		 }
		 GlobalUnlock( blob.m_hData );
	  }
	}

	return *this;
}
Exemplo n.º 14
0
void ProcessImage(HBITMAP image)
{
	return;
	DIBSECTION dibsection = {0};
	int nBytes = 0;
	
	nBytes = ::GetObject( image, sizeof( DIBSECTION ), &dibsection );
	if( nBytes == sizeof( DIBSECTION ) )
	{
		size_t width = dibsection.dsBmih.biWidth;
		size_t height = abs( dibsection.dsBmih.biHeight );
		size_t BPP = dibsection.dsBmih.biBitCount;
		if( BPP != 32 )
			return;

		void *bits = dibsection.dsBm.bmBits;
		size_t pitch = (((width * BPP) + 31) / 32) * 4;
		for(size_t i = 0; i != width; ++i)
		{
			for(size_t j = 0; j < height; ++j)
			{
				LPBYTE pucColor = LPBYTE( bits )+(j*pitch)+((i*BPP)/8);
				pucColor[0] = pucColor[0] * pucColor[3] / 255;
				pucColor[1] = pucColor[1] * pucColor[3] / 255;
				pucColor[2] = pucColor[2] * pucColor[3] / 255;
			}
		}
	}
	else
		assert(0);
}
Exemplo n.º 15
0
fsInternetResult fsHttpFiles::LoadFile()
{
	UINT uToRead = 1000;		
	const FLOAT fInc = 1.2f;	

	fsInternetResult ir;    

	UINT64 uFileSize = m_httpFile.GetFileSize ();
	UINT64 uMax = uFileSize;	
	UINT64 uPos = 0;	
	DWORD dwRead;	

	if (uMax == _UI64_MAX)	
		uMax = 100000;		

	SAFE_DELETE_ARRAY (m_pszFileBuffer);

	fsnew (m_pszFileBuffer, char, int (uMax+1));

	int cZeroReads = 0;
	
	do
	{
		if (uToRead > uFileSize - uPos)
			uToRead = UINT (uFileSize - uPos);
		
		if (uPos + uToRead > uMax) 
		{

			
			uMax = UINT64 ((INT64)uMax * fInc);

			
			LPSTR psz = 0;
			fsnew (psz, char, int (uMax+1));
			CopyMemory (psz, m_pszFileBuffer, UINT (uPos));
			delete [] m_pszFileBuffer;
			m_pszFileBuffer = psz;
		}

		ir = m_httpFile.Read (LPBYTE (m_pszFileBuffer+uPos), uToRead, &dwRead);
		if (ir != IR_SUCCESS)
		{
			delete m_pszFileBuffer;
			return ir;
		}

		uPos += dwRead;	

		if (dwRead == 0)
		{
			cZeroReads ++;
			if (cZeroReads < 3 && uFileSize != _UI64_MAX)
				dwRead = 1; 
		}
		else
			cZeroReads = 0;   

	}
Exemplo n.º 16
0
void NewDeviceWidget::onSetButtonClicked()
{


	//Check whether the Device Name is of appropriate length
	if (deviceNameInput->text().count() < 1 || deviceNameInput->text().count() > 16) //1 - 16 is the valid length range
	{
		deviceNameLabel->setText("The device name must be between 1-12 characters:");
		deviceNameLabel->setPalette(errorTextPalette);
	}
	else
	{
		 
		/* Save this Device Name and Type to the Registry */

		HKEY inssidiousHKCU;
		if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\Inssidious\\DevicePairs", 0, 0, 0, KEY_WRITE, 0, &inssidiousHKCU, 0))
		{
			RegSetValueEx(
				inssidiousHKCU,
				QString(MAC + "-Name").toStdWString().c_str(),
				0,
				REG_SZ,
				LPBYTE(deviceNameInput->text().utf16()),
				deviceNameInput->text().size() * sizeof(wchar_t)
			);


			RegSetValueEx(
				inssidiousHKCU,
				QString(MAC + "-Type").toStdWString().c_str(),
				0,
				REG_SZ,
				LPBYTE(deviceTypeComboBox->currentText().utf16()),
				deviceTypeComboBox->currentText().size() * sizeof(wchar_t)
				);
		}


		/* Send out the name and type values */

		emit setDeviceInfo(MAC, deviceNameInput->text(), deviceTypeComboBox->currentText());

	}

}
Exemplo n.º 17
0
// only CMemFile supports "direct buffering" interaction with CArchive
UINT CMemFile::GetBufferPtr(UINT nCommand, UINT nCount,
	void** ppBufStart, void**ppBufMax)
{
	ASSERT(nCommand == bufferCheck || nCommand == bufferCommit ||
		nCommand == bufferRead || nCommand == bufferWrite);

	if (nCommand == bufferCheck)
		return 1;   // just a check for direct buffer support

	if (nCommand == bufferCommit)
	{
		// commit buffer
		ASSERT(ppBufStart == NULL);
		ASSERT(ppBufMax == NULL);
		m_nPosition += nCount;
		if (m_nPosition > m_nFileSize)
			m_nFileSize = m_nPosition;
		return 0;
	}

	ASSERT(nCommand == bufferWrite || nCommand == bufferRead);
	ASSERT(ppBufStart != NULL);
	ASSERT(ppBufMax != NULL);

	// when storing, grow file as necessary to satisfy buffer request
	if (nCommand == bufferWrite && m_nPosition + nCount > m_nBufferSize)
		GrowFile(m_nPosition + nCount);

	// store buffer max and min
	*ppBufStart = m_lpBuffer + m_nPosition;

	// end of buffer depends on whether you are reading or writing
	if (nCommand == bufferWrite)
		*ppBufMax = m_lpBuffer + min(m_nBufferSize, m_nPosition + nCount);
	else
	{
		if (nCount == (UINT)-1)
			nCount = m_nBufferSize - m_nPosition;
		*ppBufMax = m_lpBuffer + min(m_nFileSize, m_nPosition + nCount);
		m_nPosition += LPBYTE(*ppBufMax) - LPBYTE(*ppBufStart);
	}

	// return number of bytes in returned buffer space (may be <= nCount)
	return LPBYTE(*ppBufMax) - LPBYTE(*ppBufStart);
}
Exemplo n.º 18
0
//--------------------------------------------------------------------------------
CNTService::~CNTService()
	{
	AFX_MANAGE_STATE_IF_DLL

	ReportStatus(SERVICE_STOPPED);

	g_this = NULL;
	delete[] LPBYTE(m_pUserSID);
	}
Exemplo n.º 19
0
QByteArray QCSPPrivate::provParam( HCRYPTPROV h, DWORD param, DWORD flags )
{
	DWORD size = 0;
	if( !CryptGetProvParam( h, param, 0, &size, flags ) )
		return QByteArray();
	QByteArray data( size, 0 );
	if( !CryptGetProvParam( h, param, LPBYTE(data.data()), &size, flags ) )
		return QByteArray();
	return data;
}
Exemplo n.º 20
0
QByteArray QCSPPrivate::keyParam( HCRYPTKEY key, DWORD param, DWORD flags )
{
	DWORD size = 0;
	if( !CryptGetKeyParam( key, param, 0, &size, flags ) )
		return QByteArray();
	QByteArray data( size, 0 );
	if( !CryptGetKeyParam( key, param, LPBYTE(data.data()), &size, flags ) )
		return QByteArray();
	return data;
}
Exemplo n.º 21
0
QCSP::PinStatus QCSP::login( const TokenData &t )
{
	if( !d->h )
		return PinUnknown;

	PinDialog dialog( PinDialog::Pin2Type, t, qApp->activeWindow() );
	if( !dialog.exec() )
		return PinCanceled;
	return CryptSetProvParam( d->h, PP_SIGNATURE_PIN, LPBYTE(dialog.text().utf16()), 0 ) ? PinOK : PinUnknown;
}
Exemplo n.º 22
0
QStringList QPCSC::drivers() const
{
#ifdef Q_OS_WIN
	HDEVINFO h = SetupDiGetClassDevs( 0, 0, 0, DIGCF_ALLCLASSES | DIGCF_PRESENT );
	if( !h )
		return QStringList();

	SP_DEVINFO_DATA info = { sizeof(SP_DEVINFO_DATA) };
	QStringList list;
	for( DWORD i = 0; SetupDiEnumDeviceInfo( h, i, &info ); i++ )
	{
		DWORD size = 0;
		WCHAR data[1024];

		SetupDiGetDeviceRegistryPropertyW( h, &info,
			SPDRP_CLASS, 0, LPBYTE(data), sizeof(data), &size );
		if( _wcsicmp( data, L"SmartCardReader" ) != 0 )
			continue;

		DWORD conf = 0;
		SetupDiGetDeviceRegistryPropertyW( h, &info,
			SPDRP_CONFIGFLAGS, 0, LPBYTE(&conf), sizeof(conf), &size );
		if( conf & CONFIGFLAG_DISABLED )
			continue;

		SetupDiGetDeviceRegistryPropertyW( h, &info,
			SPDRP_DEVICEDESC, 0, LPBYTE(data), sizeof(data), &size );
		QString name( (QChar*)data );

		SetupDiGetDeviceRegistryPropertyW( h, &info,
			SPDRP_HARDWAREID, 0, LPBYTE(data), sizeof(data), &size );

		list << QString( "%1 (%2)").arg( name, QString( (QChar*)data ) );
	}
	SetupDiDestroyDeviceInfoList( h );

	return list;
#else
	return readers();
#endif
}
Exemplo n.º 23
0
QByteArray QPCSCReaderPrivate::attrib( DWORD id ) const
{
	DWORD size = 0;
	LONG err = SCardGetAttrib( card, id, 0, &size );
	if( err != SCARD_S_SUCCESS || !size )
		return QByteArray();
	QByteArray data( size, 0 );
	err = SCardGetAttrib( card, id, LPBYTE(data.data()), &size );
	if( err != SCARD_S_SUCCESS || !size )
		return QByteArray();
	return data;
}
Exemplo n.º 24
0
BOOL GetTaskExpWinVer(HTASK hTask, LPWORD pwVer)
{
    LPBYTE pTDB = LPBYTE(MAKELP(hTask, 0));
    if (!BAD_PTR(pTDB, 0xfc) &&
        pTDB[0xfa] == 'T' && pTDB[0xfb] == 'D' &&
        (pTDB[0x16] & 0x10) == 0x00) // !Win32 task
    {
        *pwVer = MAKEWORD(pTDB[0x1a], pTDB[0x1b]);
        return (TRUE);
    }
    return (FALSE);
}
Exemplo n.º 25
0
BOOL GetModuleExpWinVer(HMODULE hModule, LPWORD pwVer)
{
    hModule = GetExePtr(hModule);
    LPBYTE pMDB = LPBYTE(MAKELP(hModule, 0));
    if (!BAD_PTR(pMDB, 0x40) &&
        pMDB[0x00] == 'N' && pMDB[0x01] == 'E' &&
        (pMDB[0x0c] & 0x10) == 0x00) // !Win32 module
    {
        *pwVer = MAKEWORD(pMDB[0x3e], pMDB[0x3f]);
        return (TRUE);
    }
    return (FALSE);
}
Exemplo n.º 26
0
QByteArray QCSP::decrypt( const QByteArray &data )
{
	HCRYPTKEY key = 0;
	if( !CryptGetUserKey( d->h, AT_KEYEXCHANGE, &key ) )
		return QByteArray();

	QByteArray rev = reverse( data );
	DWORD size = rev.size();
	bool result = CryptDecrypt( key, 0, true, 0, LPBYTE(rev.data()), &size );
	CryptDestroyKey( key );

	return result ? rev : QByteArray();
}
Exemplo n.º 27
0
QByteArray QCSP::sign( int method, const QByteArray &digest )
{
	ALG_ID alg = 0;
	switch( method )
	{
	case NID_sha1: alg = CALG_SHA1; break;
	case NID_sha256: alg = CALG_SHA_256; break;
	case NID_sha384: alg = CALG_SHA_384; break;
	case NID_sha512: alg = CALG_SHA_512; break;
	case NID_sha224:
	default: return QByteArray();
	}

	HCRYPTHASH hash = 0;
	if( !CryptCreateHash( d->h, alg, 0, 0, &hash ) )
		return QByteArray();

	if( !CryptSetHashParam( hash, HP_HASHVAL, LPBYTE(digest.constData()), 0 ) )
	{
		CryptDestroyHash( hash );
		return QByteArray();
	}

	DWORD size = 256;
	QByteArray sig( size, 0 );
	if( CryptSignHashW( hash, AT_SIGNATURE, 0, 0, LPBYTE(sig.data()), &size ) )
		sig.resize( size );
	else
		sig.clear();
	switch( GetLastError() )
	{
	case ERROR_CANCELLED: d->error = PinCanceled; break;
	default: break;
	}

	CryptDestroyHash( hash );
	return reverse( sig );
}
Exemplo n.º 28
0
BOOL SetModuleExpWinVer(HMODULE hModule, WORD wVer)
{
    hModule = GetExePtr(hModule);
    LPBYTE pMDB = LPBYTE(MAKELP(hModule, 0));
    if (!BAD_PTR(pMDB, 0x40) &&
        pMDB[0x00] == 'N' && pMDB[0x01] == 'E' &&
        (pMDB[0x0c] & 0x10) == 0x00) // !Win32 module
    {
        pMDB[0x3e] = LOBYTE(wVer); // minor
        pMDB[0x3f] = HIBYTE(wVer); // major
        return (TRUE);
    }
    return (FALSE);
}
Exemplo n.º 29
0
QByteArray QPCSCReader::Private::attrib( DWORD id ) const
{
	if(!card)
		return QByteArray();
	DWORD size = 0;
	LONG err = SC(GetAttrib, card, id, nullptr, &size);
	if( err != SCARD_S_SUCCESS || !size )
		return QByteArray();
	QByteArray data(int(size), 0);
	err = SC(GetAttrib, card, id, LPBYTE(data.data()), &size);
	if( err != SCARD_S_SUCCESS || !size )
		return QByteArray();
	return data;
}
Exemplo n.º 30
0
BOOL SetTaskExpWinVer(HTASK hTask, WORD wVer)
{
    LPBYTE pTDB = LPBYTE(MAKELP(hTask, 0));
    if (!BAD_PTR(pTDB, 0xfc) &&
        pTDB[0xfa] == 'T' && pTDB[0xfb] == 'D' &&
        (pTDB[0x16] & 0x10) == 0x00) // !Win32 task
    {
        WORD wSel = MAKEWORD(pTDB[0x20], pTDB[0x21]);
        if (SetQueueExpWinVer(HGLOBAL(wSel), wVer))
        {
            pTDB[0x1a] = LOBYTE(wVer); // minor
            pTDB[0x1b] = HIBYTE(wVer); // major
            return (TRUE);
        }
    }
    return (FALSE);
}