예제 #1
0
파일: RegUtils.cpp 프로젝트: tulip2014/base
	//***************************************************************************************************
	// write string to registry, if the key path is not exist, will create one
	bool WriteDWORD( HKEY hKey, LPCTSTR lpcsPath, LPCTSTR lpcsSubPath, LPCTSTR lpcsKey, DWORD dwValue )
	{
		if ( lpcsPath == NULL || _tcslen( lpcsPath ) < 1 )	{
			_ASSERT( 0 );
			return false;
		}

		if ( lpcsSubPath != NULL )	{
			_TCHAR tcsPath[MAX_PATH];
			StringCbPrintf( tcsPath, MAX_PATH* sizeof(_TCHAR), _T("%s\\%s"), lpcsPath, lpcsSubPath );
			return WriteDWORD( hKey, tcsPath, lpcsKey, dwValue );
		}
		else {
			return WriteDWORD( hKey, lpcsPath, lpcsKey, dwValue );
		}
	}
static nsresult
GenerateType1Msg(void **outBuf, uint32_t *outLen)
{
  //
  // verify that bufLen is sufficient
  //
  *outLen = NTLM_TYPE1_HEADER_LEN;
  *outBuf = nsMemory::Alloc(*outLen);
  if (!*outBuf)
    return NS_ERROR_OUT_OF_MEMORY;

  //
  // write out type 1 msg
  //
  void *cursor = *outBuf;

  // 0 : signature
  cursor = WriteBytes(cursor, NTLM_SIGNATURE, sizeof(NTLM_SIGNATURE));

  // 8 : marker
  cursor = WriteBytes(cursor, NTLM_TYPE1_MARKER, sizeof(NTLM_TYPE1_MARKER));

  // 12 : flags
  cursor = WriteDWORD(cursor, NTLM_TYPE1_FLAGS);

  //
  // NOTE: it is common for the domain and workstation fields to be empty.
  //       this is true of Win2k clients, and my guess is that there is
  //       little utility to sending these strings before the charset has
  //       been negotiated.  we follow suite -- anyways, it doesn't hurt
  //       to save some bytes on the wire ;-)
  //

  // 16 : supplied domain security buffer (empty)
  cursor = WriteSecBuf(cursor, 0, 0);

  // 24 : supplied workstation security buffer (empty)
  cursor = WriteSecBuf(cursor, 0, 0);

  return NS_OK;
}
예제 #3
0
String			TSearchFilesFrm::GetSearchData()
{
	AnsiString data;
	AnsiString content_text = edtSearchContent->Text;

	if(cbSearchMode->ItemIndex == 0)
	{
		data = content_text;
	}
	else if(cbSearchMode->ItemIndex == 1)
	{
		data = BinToStr(content_text.c_str(), content_text.Length());
	}
	else if(cbSearchMode->ItemIndex == 2)
	{
		DWORD num = content_text.ToInt();
		data.SetLength(4);
		int pos = 0;
		WriteDWORD(data.c_str(), pos, num);
		data = BinToStr(data.c_str(), data.Length());
	}
	else if(cbSearchMode->ItemIndex == 3)
	{
		WORD num = content_text.ToInt();
		data.SetLength(2);
		int pos = 0;
		WriteWORD(data.c_str(), pos, num);
		data = BinToStr(data.c_str(), data.Length());
	}
	else if(cbSearchMode->ItemIndex == 4)
	{
		BYTE num = content_text.ToInt();
		data.SetLength(1);
		int pos = 0;
		WriteBYTE(data.c_str(), pos, num);
		data = BinToStr(data.c_str(), data.Length());
	}
	return	data;
}
예제 #4
0
    void PatchBlob( Blob& rOutputBlob, const ShaderArgs& rArgs, const Blob& rTemplateBlob, size_t nTemplateIsaStart )
    {
        
        //
        //  Summary of what I know about the blob layout:
        //
        // 
        //  DWORD 0: 0x00003142  This is a 4CC code "B1"
        //  DWORD 1: 0x020423c8.  Version number?  Device number? dunno
        //  DWORD 2 looks like it contains the blob length minus some constant
        //            but this field is itself shifted one byte.  the lower 8 bits are 0xB...?
        //  ^
        //  |  Rest is unknown
        //  V
        //  DWORD 16 threadgroup size X
        //  DWORD 17 " " Y (-1 if not specified)
        //  DWORD 18 " " Z (-1 if not specified)
        //  ^
        //  |
        //  | Unknown length and contents
        //  |   AT SOME POINT IN HERE, WE STOP BEING DWORD ALIGNED
        //  |
        //  |
        //  V 
        //  ^
        //  |  Various pre-isa fields, a few of which are understood
        //  |      (see below)
        //  V
        //  ^
        //  |
        //  | ISA   !NOT DWORD ALIGNED!
        //  |
        //  V
        //  ^
        //  |
        //  | Padding to align ISA to 64 bytes
        //  |
        //  V
        //  ^
        //  |
        //  | 512 bytes of zero padding
        //  |
        //  V
        //  CURBE data
        //   ....
        //   ....
        //  ^
        //  |
        //  | Unknown length and content
        //  V
        //  Last two DWORDS are a hash


        //
        //    By comparing different shaders I was able to decipher the important looking parts of the blob prior to the isa
        //     
        //        At isa-24 is the number of threads in the OpenGL workgroup grid (width*height*depth)
        //        At isa-32 is the SIMD mode (0 for SIMD0, 1 for SIMD16)
        //        At isa-104 and isa-702 is the number of 256-bit CURBE entries per hardware thread
        //        At isa-100 and isa-700 is the number of HW threads
        //        At isa-4 and isa-128 is the length of the isa block (including padding)
        //        At isa-40 is the length of the CURBE data
        //        
        //    
        //     The Isa block is always padded with 512 bytes (128 DWORDS) of zero.  
        //        Intel docs state that the 128 bytes following the last instruction are MBZ
        //          because instruction prefetching will yank those bytes in before the EU realizes the thread is done
        //
        //       512 bytes is more padding than we need.  Either the docs are wrong, or the driver is over-zealous
        //           Or else there's something there I haven't figured out yet.
 
        const unsigned char* pTemplate = ((const unsigned char*)rTemplateBlob.GetBytes());
        const unsigned char* isa = pTemplate  + nTemplateIsaStart;
        
        DWORD dwGridSize        = FetchDWORD(isa-24);  // width*height*depth for the GL threadgroup
        DWORD dwMode            = FetchDWORD(isa-32);  // 0 for SIMD8, 1 for SIMD16          
        DWORD dwCURBEEntrySize  = FetchDWORD(isa-104); 
        DWORD dwThreadCount     = FetchDWORD(isa-100); // also at isa-700
        DWORD dwIsaLength       = FetchDWORD(isa-4);   // also at isa-128
        DWORD dwCURBELength     = FetchDWORD(isa-40);

        size_t nPreIsaLength    = nTemplateIsaStart;
        size_t nPostCURBEStart  = nTemplateIsaStart + dwIsaLength + dwCURBELength;
        size_t nPostCURBELength = rTemplateBlob.GetLength() - nPostCURBEStart;

        size_t nNewIsaLength    = 512 + ( (rArgs.nIsaLength + 63) & ~63);
        size_t nNewCURBELength  =  rArgs.nCURBEAllocsPerThread*rArgs.nDispatchThreadCount*32;

        size_t nNewBlobSize = nPreIsaLength + nPostCURBELength + nNewIsaLength + nNewCURBELength;
        
        rOutputBlob.SetLength(nNewBlobSize);

        unsigned char* pNewBlob = (unsigned char*) rOutputBlob.GetBytes();
        unsigned char* pNewIsa       = pNewBlob  + nPreIsaLength;
        unsigned char* pNewCURBE     = pNewIsa   + nNewIsaLength;
        unsigned char* pNewPostCURBE = pNewCURBE + nNewCURBELength;

        // copy pre-Isa blob
        memcpy( pNewBlob, pTemplate, nPreIsaLength );

        // copy the new Isa into place and add the padding
        memcpy( pNewIsa, rArgs.pIsa, rArgs.nIsaLength );
        memset( pNewIsa + rArgs.nIsaLength, 0, nNewIsaLength - rArgs.nIsaLength  );

        // copy the new CURBE into place
        memcpy( pNewCURBE, rArgs.pCURBE, nNewCURBELength );

        // copy post-CURBE blob
        memcpy(pNewPostCURBE, pTemplate + nPostCURBEStart, nPostCURBELength );

        // override the fields we might need to change

        DWORD nDispatchMode = 0;
        switch( rArgs.nSIMDMode )
        {
        case 16: nDispatchMode = 1; break;
        case 32: nDispatchMode = 2; break;
        case 8:
        default:
           break; // keep SIMD8 dispatch (mode=0)
        }

        WriteDWORD( pNewIsa-32, nDispatchMode );

        // change thread grid size
        WriteDWORD( pNewIsa-24, (8<<nDispatchMode)*rArgs.nDispatchThreadCount );

        // change HW thread count
        WriteDWORD( pNewIsa-100, rArgs.nDispatchThreadCount );
        WriteBYTE( pNewIsa-700, rArgs.nDispatchThreadCount );

        // change CURBE allocation size
        WriteDWORD( pNewIsa-104, rArgs.nCURBEAllocsPerThread ); 
        WriteBYTE( pNewIsa-702, rArgs.nCURBEAllocsPerThread ); 

        // change CURBE length
        WriteDWORD( pNewIsa-40, nNewCURBELength );

        // change Isa length
        WriteDWORD( pNewIsa-4, nNewIsaLength );
        WriteDWORD( pNewIsa-128, nNewIsaLength );

        // Near the top, we have blob_length minus some constant.  696, in the case of our sample blobs
        //  This looks to be a "how many bytes follow" field
        //
        //   Not sure if the 696 is fixed or varies with the particular GLSL program
        //    Let's assume it varies...
        //
        DWORD nSizeDifference = rTemplateBlob.GetLength() - FetchDWORD( pTemplate + 13 );
        WriteDWORD( pNewBlob + 13, nNewBlobSize - nSizeDifference );

        // fix the hash
        DriverHashFunction( (DWORD*)(pNewBlob + (nNewBlobSize-8)), (DWORD*)pNewBlob, (nNewBlobSize-8)/4 );

    }
예제 #5
0
HRESULT CRegistry::WriteBOOL(LPCTSTR pszKey, BOOL bValue)
{
  return WriteDWORD(pszKey, bValue);
}