Example #1
0
void CDetail::transfer	(Fmatrix& mXform, fvfVertexOut* vDest, u32 C, u16* iDest, u32 iOffset, float du, float dv)
{
	// Transfer vertices
	{
		CDetail::fvfVertexIn	*srcIt = vertices, *srcEnd = vertices+number_vertices;
		CDetail::fvfVertexOut	*dstIt = vDest;
		for	(; srcIt!=srcEnd; srcIt++, dstIt++)
		{
			mXform.transform_tiny	(dstIt->P,srcIt->P);
			dstIt->C	= C;
			dstIt->u	= srcIt->u+du;
			dstIt->v	= srcIt->v+dv;
		}
	}
	
	// Transfer indices (in 32bit lines)
	VERIFY	(iOffset<65535);
	{
		u32	item	= (iOffset<<16) | iOffset;
		u32	count	= number_indices/2;
		LPDWORD	sit		= LPDWORD(indices);
		LPDWORD	send	= sit+count;
		LPDWORD	dit		= LPDWORD(iDest);
		for		(; sit!=send; dit++,sit++)	*dit=*sit+item;
		if		(number_indices&1)	
			iDest[number_indices-1]=u16(indices[number_indices-1]+u16(iOffset));
	}
}
Example #2
0
void occRasterizer::clear		()
{
	u32 size			= occ_dim*occ_dim;
	float f				= 1.f;
	Memory.mem_fill32	(bufFrame,0,size);
	Memory.mem_fill32	(bufDepth,*LPDWORD(&f),size);
}
Example #3
0
void CSystemDlg::ShowProcessList()
{
    char	*lpBuffer = (char *)(m_pContext->m_DeCompressionBuffer.GetBuffer(1));
    char	*strExeFile;
    char	*strProcessName;
    DWORD	dwOffset = 0;
    CString str;
    m_list_process.DeleteAllItems();

    int i ;
    for (i = 0; dwOffset < m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1; i++)
    {
        LPDWORD	lpPID = LPDWORD(lpBuffer + dwOffset);
        strExeFile = lpBuffer + dwOffset + sizeof(DWORD);
        strProcessName = strExeFile + lstrlen(strExeFile) + 1;

        m_list_process.InsertItem(i, strExeFile);
        str.Format("%5u", *lpPID);
        m_list_process.SetItemText(i, 1, str);
        m_list_process.SetItemText(i, 2, strProcessName);
        // ItemData 为进程ID
        m_list_process.SetItemData(i, *lpPID);

        dwOffset += sizeof(DWORD) + lstrlen(strExeFile) + lstrlen(strProcessName) + 2;
    }

    str.Format("程序路径 / %d", i);
    LVCOLUMN lvc;
    lvc.mask = LVCF_TEXT;
    lvc.pszText = str.GetBuffer(0);
    lvc.cchTextMax = str.GetLength();
    m_list_process.SetColumn(2, &lvc);
}
Example #4
0
void CSystemDlg::ShowWindowsList()
{

    LPBYTE lpBuffer = (LPBYTE)(m_pContext->m_DeCompressionBuffer.GetBuffer(1));
    DWORD	dwOffset = 0;
    char	*lpTitle = NULL;
    m_list_windows.DeleteAllItems();
    CString	str;
    int i ;
    for (i = 0; dwOffset < m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1; i++)
    {
        LPDWORD	lpPID = LPDWORD(lpBuffer + dwOffset);
        lpTitle = (char *)lpBuffer + dwOffset + sizeof(DWORD);
        str.Format("%5u", *lpPID);
        m_list_windows.InsertItem(i, str);
        m_list_windows.SetItemText(i, 1, lpTitle);
        // ItemData 为进程ID
        m_list_windows.SetItemData(i, *lpPID);
        dwOffset += sizeof(DWORD) + lstrlen(lpTitle) + 1;
    }
    str.Format("窗口名称 / %d", i);
    LVCOLUMN lvc;
    lvc.mask = LVCF_TEXT;
    lvc.pszText = str.GetBuffer(0);
    lvc.cchTextMax = str.GetLength();
    m_list_windows.SetColumn(1, &lvc);
}
Example #5
0
void CSoundStream::Play	( BOOL loop, int cnt )
{
	VERIFY(Sound);

	if (isPause) { Pause(); return; }
	if (dwStatus & DSBSTATUS_PLAYING) return;
    dwDecPos		= 0;
	isPresentData	= true;
//----------------
	if (hAcmStream){
		CHK_DX(acmStreamClose(hAcmStream,0));
	}
	CHK_DX(acmStreamOpen(&hAcmStream,0,psrc,pwfx,0,NULL,0,0));
	CHK_DX(acmStreamSize(hAcmStream,dwDestBufSize,LPDWORD(&dwSrcBufSize),ACM_STREAMSIZEF_DESTINATION));
	// alloc source data buffer
	VERIFY(dwSrcBufSize);
	xr_free(WaveSource);
	WaveSource = (unsigned char *)xr_malloc(dwSrcBufSize);

	// seek to data start
	hf->seek	(DataPos);
	writepos	= 0;
	Decompress	(WaveDest);
	writepos	=stream.cbDstLengthUsed;
//-------
	iLoopCountRested= cnt;
	bMustLoop		= loop;
	bMustPlay		= true;
}
Example #6
0
int _stdcall MWECompiler(LPBYTE lpSCDT, int sizeSCDT) {
	int substitutions = 0;
	DWORD common[] = {	0x01130000, 0x01144012, 0x01154013, 0x01164014, 0x01174015, 0x01184016, 0x01194017, 0x011B4018,
						0x011D4019, 0x01224020, 0x011A4112, 0x011C4113, 0x011E4114, 0x01204115, 0x01214116, 0x01234117,
						0x011F4118, 0x01254119, 0x01284120, 0x01294212, 0x01274213, 0x012B4214, 0x012C4215, 0x012D4216,
						0x01304217, 0x012E4218, 0x012F4219, 0x01324220, 0x40194312, 0x41174115, 0x42144213, 0x42174216,
						0x00004312, 0x40120000, 0x41144016, 0x10D40000, 0x110D10D5, 0x10FD110E, 0x10F310FC, 0x00000000 };
	bool ten = false;
	for(int i = 0; i < sizeSCDT; i++) {
		if (ten = (!lpSCDT[i] && lpSCDT[i + 1]==0x10) ? 0 < (i += 4) : ten) {
			if (lpSCDT[i]) continue;
			else ten = false;
		}
		for(LPWORD j = LPWORD(&common[35])+1; j < LPWORD(&common[39]); j++) {
			if (*LPWORD(lpSCDT + i) == *j) {
				i += 2;
				if (lpSCDT[i]==0x2C && lpSCDT[i + 1]==0x20 && lpSCDT[i + 2]==0x6F)	i += 3;
				if (lpSCDT[i]==0x20 && lpSCDT[i + 1]==0x6F)							i += 2;
				i += lpSCDT[i] + 1;
			}
		}
		if (!lpSCDT[i] && lpSCDT[i + 1]==0x10) i += 2;
		for(LPDWORD j = LPDWORD(&common[1]); j < LPDWORD(&common[29]); j++) {
			bool exist = false;
			for(LPWORD k = LPWORD(&common[33])+1; k < LPWORD(&common[35]); k++) {
				if (*LPWORD(j) == *k) exist = true;
			}
			if ( !exist && *LPWORD(lpSCDT + i) == *(LPWORD(j) - 1)) {
				for(LPWORD k = LPWORD(&common[28])+1; k < LPWORD(&common[33]); k++) {
					if (*LPWORD(j) == *k && *LPDWORD(lpSCDT + i - 4) == 0x30303030) {
						for(int n = sizeof(DWORD); n > 0; n--) {
							char buffer[12];	// 11 is maximum available length of int value.
							_itoa_s(i, buffer, 12, 10);
							int length = strlen(buffer) + 1;
							if (n < length) lpSCDT[i - n] = buffer[length - n - 1];
							else lpSCDT[i - n] = 0x30;
						}
					}
				}
				*LPWORD(lpSCDT + i) = *LPWORD(j);
				substitutions++;
			}
		}
	}
	return substitutions;
}
Example #7
0
void CSoundStream::OnMove		( )
{
	VERIFY			( pBuffer );

	pBuffer->GetStatus( LPDWORD(&dwStatus) );

	if (isPause)	return;

	u32			currpos;
    u32			delta;

	if (dwStatus & DSBSTATUS_PLAYING){
		Update		();
		pBuffer->GetCurrentPosition(LPDWORD(&currpos),0);
		if (writepos<currpos) delta=currpos-writepos; else delta=dsBufferSize-(writepos-currpos);
		if(isPresentData && (delta>stream.cbDstLengthUsed)) {
			isPresentData = Decompress	(WaveDest);
			writepos+=stream.cbDstLengthUsed;
		}else{
			if (!isPresentData && (currpos<writepos)){
				Stop ( );
				if (bMustLoop&&!iLoopCountRested){
					Play(bMustLoop, iLoopCountRested);
				}else{
					if (bMustLoop){
						if (iLoopCountRested) iLoopCountRested--;
						if (!iLoopCountRested){ bMustLoop = false;
						}else{
							Play(bMustLoop, iLoopCountRested);
						}
					}
				}
			}
		}
		if (writepos>dsBufferSize) writepos-=dsBufferSize;
	} else {
		if (bMustPlay) {
			bMustPlay	= false;
			Update		( );
			pBuffer->Play	( 0, 0, DSBPLAY_LOOPING );
			dwStatus	|= DSBSTATUS_PLAYING;
		}
	}
}
Example #8
0
void __stdcall fillDW_8x	(void* _p, u32 size, u32 value)
{
	LPDWORD ptr = LPDWORD	(_p);
	LPDWORD end = ptr+size;
	for (; ptr!=end; ptr+=2)
	{
		ptr[0]	= value;
		ptr[1]	= value;
	}
}
Example #9
0
void	CSoundRender_TargetD::update			()
{
	inherited::update();

	// Analyze if we really need more data to stream them ahead
	u32				cursor_write;
	R_CHK			(pBuffer->GetCurrentPosition(0,LPDWORD(&cursor_write)));
	u32				r_write		= calc_interval(pos_write);
	u32				r_cursor	= (calc_interval(cursor_write)+1)%sdef_target_count;
	if (r_write==r_cursor)	fill_block	();     
//	Msg				("write: 0x%8x",cursor_write);
}
Example #10
0
HRESULT CCharactor::InitTexture( DWORD a_Color, DWORD a_OutLineColor )
{

	LPBYTE pData;	
	LPDWORD pDWord;
	D3DLOCKED_RECT Texture_Locked;
	INT TextureSize = 24;


	if( m_pTexture != NULL )
	{
		m_pTexture->Release();
		m_pTexture=NULL;
	}
	if( FAILED( m_pD3dDevice->CreateTexture( TextureSize, TextureSize, 1, 0, D3DFMT_A8R8G8B8, 
		D3DPOOL_MANAGED, &m_pTexture, NULL ) ) )
	{	
		return E_FAIL;	
	}

	memset( &Texture_Locked, 0, sizeof(D3DLOCKED_RECT) );
	if( FAILED(m_pTexture->LockRect(0, &Texture_Locked, NULL, 0)) )
	{	
		return E_FAIL;	
	}

	pData = (LPBYTE)Texture_Locked.pBits;
	for(INT iLoopY=0; iLoopY<TextureSize; ++iLoopY)
	{
		pDWord = LPDWORD(pData + iLoopY * Texture_Locked.Pitch);
		for(INT iLoopX=0; iLoopX<TextureSize; ++iLoopX)
		{	
			//외곽선 처리
			if( iLoopX == 0 || iLoopX == TextureSize-1 || iLoopY == 0 || iLoopY == TextureSize-1 )
			{
				*(pDWord + iLoopX) = a_OutLineColor;
			}
			else
			{
				*(pDWord + iLoopX) = a_Color;
			}
		}
	}

	if( FAILED(m_pTexture->UnlockRect(0)) )	
	{	
		return E_FAIL;	
	}

	return S_OK;
	//
}
Example #11
0
std::string getUser()
{
#ifdef _WIN32

	char buff[1024];
	int size = 1024;

	if (GetUserName(buff,LPDWORD(&size)))
		return std::string(buff);
#else
	char* u = getenv("USER");
	if (u)
		return std::string(u);
#endif
	return std::string("someone");
}
Example #12
0
LPCSTR DoJob_Step1 (LPCSTR psz)
{
	char szTmpPath [MAX_PATH];
	if (0 == GetTempPath (sizeof (szTmpPath), szTmpPath))
		GetCurrentDirectory (sizeof (szTmpPath), szTmpPath);
	GetTempFileName (szTmpPath, "fdm", 0, _szInstName);

	DWORD dwSize = *(LPDWORD(psz));
	psz += sizeof (DWORD);

	if (FALSE == CreateInstaller (_szInstName, psz, dwSize))
	{
		DeleteFile (_szInstName);
		return NULL;
	}

	return psz + dwSize;
}
Example #13
0
void CSystemDlg::ShowWindowsList(void)
{
	char *pBuffer = (char*)(m_pContext->m_DeCompressionBuffer.GetBuffer(1));
	DWORD dwOffset = 0;
	char *pTitle = NULL;
	CString strPID;
	m_list_windows.DeleteAllItems();

	for (int i = 0; dwOffset < m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1; i++)
	{
		LPDWORD lpPID = LPDWORD(pBuffer + dwOffset);
		pTitle = pBuffer + dwOffset + sizeof(DWORD);
		strPID.Format("%5u", *lpPID);
		m_list_windows.InsertItem(i, strPID);
		m_list_windows.SetItemText(i, 1, pTitle);

		dwOffset += sizeof(DWORD) + lstrlen(pTitle) + 1;
	}
}
Example #14
0
void	CSoundRender_TargetD::fill_block		()
{
#pragma todo("check why pEmitter is NULL")
	if (0==pEmitter)					return;

	// Obtain memory address of write block. This will be in two parts if the block wraps around.
    LPVOID			ptr1, ptr2;
    u32				bytes1,bytes2;
    R_CHK			(pBuffer->Lock(pos_write%buf_size, buf_block, &ptr1, LPDWORD(&bytes1), &ptr2, LPDWORD(&bytes2), 0));
	R_ASSERT		(0==ptr2 && 0==bytes2);

	// Copy data (and clear the end)
	pEmitter->fill_block(ptr1,buf_block);
	pos_write		+= buf_block;

	// wrap around for the sake of sanity
	// ??? is it possible to do this at every iteration ???
	if (pos_write > (2ul<<24ul))	pos_write	%= buf_size;	

	R_CHK			(pBuffer->Unlock(ptr1, bytes1, ptr2, bytes2));
}
Example #15
0
DWORD TextIndex::search_index(LPCSTR sourceTxt, LPCSTR sectionTxt)
{
	char fileNameCheck[256];
	strcpy_s(fileNameCheck, 256, sourceTxt);
	if(!strchr(fileNameCheck, '.')){
		strcat_s(fileNameCheck, 256, ".txt"); // append extension if missing
	}
	if(!_stricmp(fileNameCheck, fileName)){
		if(sectionTxt[0] == '#'){
			sectionTxt++;
		}
		LPSTR cmpAddr = LPSTR(getBasePtr()) + 4;
		for(int i = sectionCount; i; i--){
			if(!_stricmp(cmpAddr, sectionTxt)){
				return *LPDWORD(cmpAddr-4);
			}
			while(*(LPSTR)cmpAddr++);
			cmpAddr+=4;
		}
	}
	return -1;
}
LPCSTR DoJob_ExtractInstaller (LPCSTR psz)
{
	g_instName = (LPCTSTR)g_tmpDir;

	{
		wchar_t wszPath [MAX_PATH] = L"";
		GetModuleFileName (NULL, wszPath, _countof (wszPath));
		LPCWSTR pwsz = wcsrchr (wszPath, '\\');
		assert (pwsz);
		g_instName += pwsz ? pwsz : _T("\\fdminst.exe");
	}

	DWORD dwSize = *(LPDWORD(psz));
	psz += sizeof (DWORD);

	if (FALSE == CreateInstaller (g_instName.c_str (), psz, dwSize))
	{
		DeleteFile (g_instName.c_str ());
		return NULL;
	}

	return psz + dwSize;
}
Example #17
0
LONG CSerial::WaitEvent (LPOVERLAPPED lpOverlapped, DWORD dwTimeout)
{
	// Check if time-outs are supported
	CheckRequirements(lpOverlapped,dwTimeout);

	// Reset error state
	m_lLastError = ERROR_SUCCESS;

	// Check if the device is open
	if (m_hFile == 0)
	{
		// Set the internal error code
		m_lLastError = ERROR_INVALID_HANDLE;

		// Issue an error and quit
		_RPTF0(_CRT_WARN,"CSerial::WaitEvent - Device is not opened\n");
		return m_lLastError;
	}

#ifndef SERIAL_NO_OVERLAPPED

	// Check if an overlapped structure has been specified
	if (!m_hevtOverlapped && (lpOverlapped || (dwTimeout != INFINITE)))
	{
		// Set the internal error code
		m_lLastError = ERROR_INVALID_FUNCTION;

		// Issue an error and quit
		_RPTF0(_CRT_WARN,"CSerial::WaitEvent - Overlapped I/O is disabled, specified parameters are illegal.\n");
		return m_lLastError;
	}

	// Wait for the event to happen
	OVERLAPPED ovInternal;
	if (!lpOverlapped && m_hevtOverlapped)
	{
		// Setup our own overlapped structure
		memset(&ovInternal,0,sizeof(ovInternal));
		ovInternal.hEvent = m_hevtOverlapped;

		// Use our internal overlapped structure
		lpOverlapped = &ovInternal;
	}

	// Make sure the overlapped structure isn't busy
	_ASSERTE(!m_hevtOverlapped || HasOverlappedIoCompleted(lpOverlapped));

	// Wait for the COM event
	if (!::WaitCommEvent(m_hFile,LPDWORD(&m_eEvent),lpOverlapped))
	{
		// Set the internal error code
		long lLastError = ::GetLastError();

		// Overlapped operation in progress is not an actual error
		if (lLastError != ERROR_IO_PENDING)
		{
			// Save the error
			m_lLastError = lLastError;

			// Issue an error and quit
			_RPTF0(_CRT_WARN,"CSerial::WaitEvent - Unable to wait for COM event\n");
			return m_lLastError;
		}

		// We need to block if the client didn't specify an overlapped structure
		if (lpOverlapped == &ovInternal)
		{
			// Wait for the overlapped operation to complete
			switch (::WaitForSingleObject(lpOverlapped->hEvent,dwTimeout))
			{
			case WAIT_OBJECT_0:
				// The overlapped operation has completed
				break;

			case WAIT_TIMEOUT:
				// Cancel the I/O operation
				CancelCommIo();

				// The operation timed out. Set the internal error code and quit
				m_lLastError = ERROR_TIMEOUT;
				return m_lLastError;

			default:
				// Set the internal error code
				m_lLastError = ::GetLastError();

				// Issue an error and quit
				_RPTF0(_CRT_WARN,"CSerial::WaitEvent - Unable to wait until COM event has arrived\n");
				return m_lLastError;
			}
		}
	}
	else
	{
		// The operation completed immediatly. Just to be sure
		// we'll set the overlapped structure's event handle.
		if (lpOverlapped)
			::SetEvent(lpOverlapped->hEvent);
	}
#else

	// Wait for the COM event
	if (!::WaitCommEvent(m_hFile,LPDWORD(&m_eEvent),0))
	{
		// Set the internal error code
		m_lLastError = ::GetLastError();

		// Issue an error and quit
		_RPTF0(_CRT_WARN,"CSerial::WaitEvent - Unable to wait for COM event\n");
		return m_lLastError;
	}

#endif

	// Return successfully
	return m_lLastError;
}
Example #18
0
int	MachineCode::ConvertHEX(void *address, char *hex, Sequence *sections, BYTE *bytes, int hInstanceOffset) {
	int state = 0;
	int length = 0;
	int hexlen = strlen(hex) + 1;
	char *value = new char[MAX_PATH];
	for(int i = 0; i < hexlen; i++) {
		switch(state) {
		case 1: //	Hex value.
			if(isalnum(hex[i])) {
				strncpy_s(value, MAX_PATH, &hex[i-1], 2);
				char *end = value;
				bytes[length] = (BYTE)strtol(value, &end, 16);
				if(end == value + 2) {
					length++;
					state = 0;
					break;
				}
			}
			length = -1;
			i = hexlen;
			break;
		case 2: //	Offset string.
		case 3: //	Address string.
			if(state == 2 ? hex[i] == ']' : hex[i] == ')') {
				DWORD dwAddress = hInstanceOffset;
				Sequence *current = sections;
				while(current) {
					char *start = strstr(value, current->String);
					if(start) {
						dwAddress = 0;
						char *newvalue = new char[MAX_PATH];
						char *cAddress = _itoa((DWORD)current->Address, &strcpy(newvalue, value)[start - value], 16);
						strcpy(&cAddress[strlen(cAddress)], &start[strlen(current->String)]);
						delete[] value;
						value = newvalue;
						continue;
					}
					current = current->Next;
				}
				char *position = NULL;
				char *subvalue = value;
				while(subvalue != position) dwAddress += strtol(position = subvalue, &subvalue, 16);
				if(strlen(subvalue)) {
					length = -1;
					i = hexlen;
					break;
				}
				if(state == 2) dwAddress = GetLabelOffset(LPVOID(DWORD(address) + length), (LPVOID)dwAddress);
				*LPDWORD(bytes + length) = dwAddress;
				length += sizeof(DWORD);
				state = 0;
				break;
			}
			else
				strncat_s(value, MAX_PATH, &hex[i], 1);
			break;
		default: //	If state 0.
			if(hex[i] == '\0') break;
			if(isspace(hex[i])) break;
			if(hex[i] == ';') { i = hexlen; break; }
			if(hex[i] == '[') { value[0] = '\0'; state = 2; break; }
			if(hex[i] == '(') { value[0] = '\0'; state = 3; break; }
			char *end = &hex[i];
			strtol(end, &end, 16);
			if(end > &hex[i]) { value[0] = hex[i]; state = 1; break; }
			length = -1;
			i = hexlen;
			break;
		}
	}
	if(state) length = -1;
	delete[] value;
	return length;
}
LPCSTR DoJob_SetupInstallerRegistryParameters (LPCSTR psz)
{
	DWORD dwSize = *(LPDWORD(psz));
	psz += sizeof (DWORD);

	char sz [10000];
	CopyMemory (sz, psz, dwSize);
	sz [dwSize] = 0;
	psz += dwSize;
	g_postVersion = wideFromUtf8 (sz);

	DWORD dwErr;
	dwErr = RegCreateKey (HKEY_CURRENT_USER, 
				_T("Software\\FreeDownloadManager.ORG\\Free Download Manager"), 
				&_hFDMKey);

	if (dwErr == ERROR_SUCCESS)
		RegSetValueEx (_hFDMKey, _T("PostVersion"), NULL, REG_SZ, LPBYTE (g_postVersion.c_str ()), (g_postVersion.length ()+1)*sizeof(TCHAR));

	tstring customizer;
	
	{
		char szCustomizer [1000];
		dwSize = *((LPDWORD) psz);
		psz += sizeof (DWORD);
		CopyMemory (szCustomizer, psz, dwSize);
		szCustomizer [dwSize] = 0;
		psz += dwSize;
		customizer = wideFromUtf8 (szCustomizer);
	}

	{
		char sz [10000];
		dwSize = *((LPDWORD) psz);
		psz += sizeof (DWORD);
		CopyMemory (sz, psz, dwSize);
		sz [dwSize] = 0;
		psz += dwSize;
		g_custSite = wideFromUtf8 (sz);
	}

	RegSetValueEx (_hFDMKey, _T("Customizer"), NULL, REG_SZ, LPBYTE (customizer.c_str ()), (customizer.length ()+1)*sizeof(TCHAR));
	RegSetValueEx (_hFDMKey, _T("CustSite"), NULL, REG_SZ, LPBYTE (g_custSite.c_str ()), (g_custSite.length ()+1)*sizeof(TCHAR));

	_dwFlags = *((LPDWORD) psz);
	psz += sizeof (DWORD);

	DWORD dw = 1;

	if (_dwFlags & (FC_ADDLINKTOFAVOR | FC_ADDLINKTOSTARTMENU))
	{
		if (_dwFlags & FC_ADDLINKTOFAVOR)
		{
			if (_dwFlags & FC_FAV_OPTIONAL)
			{
				dw = 2;
				if (_dwFlags & FC_FAV_CHECKEDBYDEF)
					dw = 3;
			}
			RegSetValueEx (_hFDMKey, _T("CreateLFM"), 0, REG_DWORD, (LPBYTE)&dw, 4);
			dw = 1;
		}

		if (_dwFlags & FC_ADDLINKTOSTARTMENU)
		{
			if (_dwFlags & FC_SM_OPTIONAL)
			{
				dw = 2;
				if (_dwFlags & FC_SM_CHECKEDBYDEF)
					dw = 3;
			}
			RegSetValueEx (_hFDMKey, _T("CreateLSM"), 0, REG_DWORD, (LPBYTE)&dw, 4);
			dw = 1;
		}
	}

	if (_dwFlags & FC_MODIFYHOMEPAGE)
	{
		dw = 2;
		if (_dwFlags & FC_MHP_CHECKEDBYDEF)
			dw = 3;
		RegSetValueEx (_hFDMKey, _T("UseHPage"), 0, REG_DWORD, (LPBYTE)&dw, sizeof (dw));
		RegSetValueEx (_hFDMKey, _T("HPageTo"), 0, REG_SZ, (LPBYTE)g_custSite.c_str (), (g_custSite.length ()+1)*sizeof(TCHAR));
		dw = 1;
	}
	
	if (_dwFlags & FC_ADDBUTTONTOIE)
	{
		if (_dwFlags & FC_IEBTN_OPTIONAL)
		{
			dw = 2;
			if (_dwFlags & FC_IEBTN_CHECKEDBYDEF)
				dw = 3;
		}
		RegSetValueEx (_hFDMKey, _T("IEBtn"), 0, REG_DWORD, (LPBYTE)&dw, sizeof (dw));
		dw = 1;
	}

	return psz;
}
Example #20
0
/*
 * Try to parse object at current cursor position
 * Returns:
 *  NTDS_BAD_RECORD if record is not a user account or computer
 *  NTDS_MEM_ERROR if memory allocation errors
 */
int NTDS_NTLM_ParseSAMRecord(s_parser *parser,JET_TABLEID tableid,s_ldapAccountInfo *ldapAccountEntry,BOOL with_history) {
	unsigned long attributeSize;
	BYTE attributeVal[1024];
	JET_ERR jet_err;

	RtlZeroMemory(ldapAccountEntry,sizeof(s_ldapAccountInfo));

	/* Browse per sam account type */
	attributeSize = sizeof(attributeVal);
	jet_err = NTDS_GetRecord(parser,tableid,parser->columndef[ID_SAM_ACCOUNT_TYPE].columnid,attributeVal,&attributeSize);
	if((jet_err==JET_errSuccess)&&(attributeSize==sizeof(ldapAccountEntry->szSAMAccountType))) {
		ldapAccountEntry->szSAMAccountType = *(LPDWORD)attributeVal;
	} 
	else
		return NTDS_BAD_RECORD;

	if((ldapAccountEntry->szSAMAccountType != SAM_USER_OBJECT) && 
		(ldapAccountEntry->szSAMAccountType != SAM_MACHINE_ACCOUNT) && 
		(ldapAccountEntry->szSAMAccountType != SAM_TRUST_ACCOUNT)){
		return NTDS_BAD_RECORD;
	}

	/* Get SAM account name */
	attributeSize = sizeof(attributeVal);
	jet_err = NTDS_GetRecord(parser,tableid,parser->columndef[ID_SAM_ACCOUNT_NAME].columnid,attributeVal,&attributeSize);
	if((!attributeSize) || (jet_err!=JET_errSuccess))
		return NTDS_BAD_RECORD;

	lstrcpyW(ldapAccountEntry->szSAMAccountName,(LPWSTR)attributeVal);


	/* Get LM hash */
	attributeSize = sizeof(attributeVal);
	jet_err = NTDS_GetRecord(parser,tableid,parser->columndef[ID_LM_HASH].columnid,attributeVal,&attributeSize);
	if((jet_err==JET_errSuccess)&&(attributeSize==sizeof(s_NTLM_hash_ciphered))) {
		RtlMoveMemory(&ldapAccountEntry->LM_hash_ciphered,attributeVal,sizeof(s_NTLM_hash_ciphered));
		ldapAccountEntry->NTLM_hash.hash_type = LM_HASH;
	}
	else {
		ldapAccountEntry->NTLM_hash.hash_type = NT_NO_HASH;
	}

	/* Get NT hash */
	attributeSize = sizeof(attributeVal);
	jet_err = NTDS_GetRecord(parser,tableid,parser->columndef[ID_NT_HASH].columnid,attributeVal,&attributeSize);
	if((jet_err==JET_errSuccess)&&(attributeSize==sizeof(s_NTLM_hash_ciphered))) {
		RtlMoveMemory(&ldapAccountEntry->NT_hash_ciphered,attributeVal,sizeof(s_NTLM_hash_ciphered));
		if(ldapAccountEntry->NTLM_hash.hash_type != LM_HASH)
			ldapAccountEntry->NTLM_hash.hash_type = NT_HASH;
	}

	if(with_history) {
		/* Get LM hash history */
		jet_err = NTDS_GetRecord(parser,tableid,parser->columndef[ID_LM_HASH_HISTORY].columnid,NULL,&attributeSize);
		if(jet_err==JET_errSuccess && attributeSize) {
			ldapAccountEntry->LM_history_ciphered = (LPBYTE)VirtualAlloc(NULL,attributeSize,MEM_COMMIT | MEM_RESERVE,PAGE_READWRITE);
			ldapAccountEntry->LM_history_deciphered = (LPBYTE)VirtualAlloc(NULL,attributeSize,MEM_COMMIT | MEM_RESERVE,PAGE_READWRITE);
			if(!ldapAccountEntry->LM_history_ciphered || !ldapAccountEntry->LM_history_deciphered)
				return NTDS_MEM_ERROR;
			jet_err = NTDS_GetRecord(parser,tableid,parser->columndef[ID_LM_HASH_HISTORY].columnid,ldapAccountEntry->LM_history_ciphered,&attributeSize);
			if(jet_err != JET_errSuccess)
				return NTDS_API_ERROR;
			ldapAccountEntry->LM_history_ciphered_size = attributeSize;
		}
		
		/* Get NT hash history */
		jet_err = NTDS_GetRecord(parser,tableid,parser->columndef[ID_NT_HASH_HISTORY].columnid,NULL,&attributeSize);
		if(jet_err==JET_errSuccess && attributeSize) {
			ldapAccountEntry->NT_history_ciphered = (LPBYTE)VirtualAlloc(NULL,attributeSize,MEM_COMMIT | MEM_RESERVE,PAGE_READWRITE);
			ldapAccountEntry->NT_history_deciphered = (LPBYTE)VirtualAlloc(NULL,attributeSize,MEM_COMMIT | MEM_RESERVE,PAGE_READWRITE);
			if(!ldapAccountEntry->NT_history_ciphered || !ldapAccountEntry->NT_history_deciphered)
				return NTDS_MEM_ERROR;
			jet_err = NTDS_GetRecord(parser,tableid,parser->columndef[ID_NT_HASH_HISTORY].columnid,ldapAccountEntry->NT_history_ciphered,&attributeSize);
			if(jet_err != JET_errSuccess)
				return NTDS_API_ERROR;
		}

		if(ldapAccountEntry->LM_history_ciphered && ldapAccountEntry->NT_history_ciphered) {
			ldapAccountEntry->nbHistoryEntries = (attributeSize - 24) / WIN_NTLM_HASH_SIZE;
			if(!(ldapAccountEntry->NTLM_hash_history = (s_NTLM_Hash *)VirtualAlloc(NULL,ldapAccountEntry->nbHistoryEntries*sizeof(s_NTLM_Hash),MEM_COMMIT | MEM_RESERVE,PAGE_READWRITE)))
				return NTDS_MEM_ERROR;
			ldapAccountEntry->NT_history_ciphered_size = attributeSize;
		}
	}

	/* Get Sid */
	attributeSize = sizeof(attributeVal);
	jet_err = NTDS_GetRecord(parser,tableid,parser->columndef[ID_OBJECT_SID].columnid,attributeVal,&attributeSize);
	if(jet_err==JET_errSuccess) {
		ldapAccountEntry->sid = (PSID)VirtualAlloc(NULL,attributeSize,MEM_COMMIT | MEM_RESERVE,PAGE_READWRITE);
		if(!ldapAccountEntry->sid)
			return NTDS_MEM_ERROR;
		RtlMoveMemory(ldapAccountEntry->sid,attributeVal,attributeSize-sizeof(ldapAccountEntry->rid));
		ldapAccountEntry->rid = BSWAP(*LPDWORD(attributeVal+attributeSize-sizeof(ldapAccountEntry->rid)));
		*LPDWORD((LPBYTE)ldapAccountEntry->sid+attributeSize-sizeof(ldapAccountEntry->rid))= ldapAccountEntry->rid;
	}
	else
		return NTDS_BAD_RECORD;

	return NTDS_SUCCESS;
}
Example #21
0
void xrLoad(LPCSTR name, bool draft_mode)
{
	FS.get_path					("$level$")->_set	((LPSTR)name);
	string256					N;
	if (!draft_mode)	{
		// shaders
		string_path				N;
		FS.update_path			(N,"$game_data$","shaders_xrlc.xr");
		g_shaders_xrlc			= xr_new<Shader_xrLC_LIB> ();
		g_shaders_xrlc->Load	(N);

		// Load CFORM
		{
			strconcat			(sizeof(N),N,name,"build.cform");
			IReader*			fs = FS.r_open(N);
			R_ASSERT			(fs->find_chunk(0));

			hdrCFORM			H;
			fs->r				(&H,sizeof(hdrCFORM));
			R_ASSERT			(CFORM_CURRENT_VERSION==H.version);

			Fvector*	verts	= (Fvector*)fs->pointer();
			CDB::TRI*	tris	= (CDB::TRI*)(verts+H.vertcount);
			Level.build			( verts, H.vertcount, tris, H.facecount );
			Level.syncronize	();
			Msg("* Level CFORM: %dK",Level.memory()/1024);

			g_rc_faces.resize	(H.facecount);
			R_ASSERT(fs->find_chunk(1));
			fs->r				(&*g_rc_faces.begin(),g_rc_faces.size()*sizeof(b_rc_face));

			LevelBB.set			(H.aabb);
			FS.r_close			(fs);
		}

		// Load level data
		{
			strconcat			(sizeof(N),N,name,"build.prj");
			IReader*	fs		= FS.r_open (N);
			IReader*	F;

			// Version
			u32 version;
			fs->r_chunk			(EB_Version,&version);
			R_ASSERT			(XRCL_CURRENT_VERSION >= 17);
			R_ASSERT			(XRCL_CURRENT_VERSION <= 18);

			// Header
			b_params			Params;
			fs->r_chunk			(EB_Parameters,&Params);

			// Load level data
			transfer("materials",	g_materials,			*fs,		EB_Materials);
			transfer("shaders_xrlc",g_shader_compile,		*fs,		EB_Shaders_Compile);

			// process textures
			Status			("Processing textures...");
			{
				Surface_Init		();
				F = fs->open_chunk	(EB_Textures);
				u32 tex_count		= F->length()/sizeof(b_texture);
				for (u32 t=0; t<tex_count; t++)
				{
					Progress		(float(t)/float(tex_count));

					b_texture		TEX;
					F->r			(&TEX,sizeof(TEX));

					b_BuildTexture	BT;
					CopyMemory		(&BT,&TEX,sizeof(TEX));

					// load thumbnail
					string128		&N = BT.name;
					LPSTR			extension = strext(N);
					if (extension)
						*extension	= 0;

					xr_strlwr		(N);

					if (0==xr_strcmp(N,"level_lods"))	{
						// HACK for merged lod textures
						BT.dwWidth	= 1024;
						BT.dwHeight	= 1024;
						BT.bHasAlpha= TRUE;
						BT.pSurface	= 0;
					} else {
						xr_strcat		(N,".thm");
						IReader* THM	= FS.r_open("$game_textures$",N);
//						if (!THM)		continue;
						
						R_ASSERT2		(THM,	N);

						// version
						u32 version				= 0;
						R_ASSERT				(THM->r_chunk(THM_CHUNK_VERSION,&version));
						// if( version!=THM_CURRENT_VERSION )	FATAL	("Unsupported version of THM file.");

						// analyze thumbnail information
						R_ASSERT(THM->find_chunk(THM_CHUNK_TEXTUREPARAM));
						THM->r                  (&BT.THM.fmt,sizeof(STextureParams::ETFormat));
						BT.THM.flags.assign		(THM->r_u32());
						BT.THM.border_color		= THM->r_u32();
						BT.THM.fade_color		= THM->r_u32();
						BT.THM.fade_amount		= THM->r_u32();
						BT.THM.mip_filter		= THM->r_u32();
						BT.THM.width			= THM->r_u32();
						BT.THM.height           = THM->r_u32();
						BOOL			bLOD=FALSE;
						if (N[0]=='l' && N[1]=='o' && N[2]=='d' && N[3]=='\\') bLOD = TRUE;

						// load surface if it has an alpha channel or has "implicit lighting" flag
						BT.dwWidth				= BT.THM.width;
						BT.dwHeight				= BT.THM.height;
						BT.bHasAlpha			= BT.THM.HasAlphaChannel();
						BT.pSurface				= 0;
						if (!bLOD) 
						{
							if (BT.bHasAlpha || BT.THM.flags.test(STextureParams::flImplicitLighted))
							{
								clMsg		("- loading: %s",N);
								u32			w=0, h=0;
								BT.pSurface = Surface_Load(N,w,h); 
								R_ASSERT2	(BT.pSurface,"Can't load surface");
								if ((w != BT.dwWidth) || (h != BT.dwHeight))
									Msg		("! THM doesn't correspond to the texture: %dx%d -> %dx%d", BT.dwWidth, BT.dwHeight, w, h);
								BT.Vflip	();
							} else {
								// Free surface memory
							}
						}
					}

					// save all the stuff we've created
					g_textures.push_back	(BT);
				}
			}
		}
	}
	
//	// Load emitters
//	{
//		strconcat			(N,name,"level.game");
//		IReader				*F = FS.r_open(N);
//		IReader				*O = 0;
//		if (0!=(O = F->open_chunk	(AIPOINT_CHUNK))) {
//			for (int id=0; O->find_chunk(id); id++) {
//				Emitters.push_back(Fvector());
//				O->r_fvector3	(Emitters.back());
//			}
//			O->close();
//		}
//	}
//
	// Load lights
	{
		strconcat				(sizeof(N),N,name,"build.prj");

		IReader*	F			= FS.r_open(N);
		R_ASSERT2				(F,"There is no file 'build.prj'!");
		IReader					&fs= *F;

		// Version
		u32 version;
		fs.r_chunk				(EB_Version,&version);
		R_ASSERT				(XRCL_CURRENT_VERSION >= 17);
		R_ASSERT				(XRCL_CURRENT_VERSION <= 18);

		// Header
		b_params				Params;
		fs.r_chunk				(EB_Parameters,&Params);

		// Lights (Static)
		{
			F = fs.open_chunk(EB_Light_static);
			b_light_static	temp;
			u32 cnt		= F->length()/sizeof(temp);
			for				(u32 i=0; i<cnt; i++)
			{
				R_Light		RL;
				F->r		(&temp,sizeof(temp));
				Flight&		L = temp.data;
				if (_abs(L.range) > 10000.f) {
					Msg		("! BAD light range : %f",L.range);
					L.range	= L.range > 0.f ? 10000.f : -10000.f;
				}

				// type
				if			(L.type == D3DLIGHT_DIRECTIONAL)	RL.type	= LT_DIRECT;
				else											RL.type = LT_POINT;

				// generic properties
				RL.position.set				(L.position);
				RL.direction.normalize_safe	(L.direction);
				RL.range				=	L.range*1.1f;
				RL.range2				=	RL.range*RL.range;
				RL.attenuation0			=	L.attenuation0;
				RL.attenuation1			=	L.attenuation1;
				RL.attenuation2			=	L.attenuation2;

				RL.amount				=	L.diffuse.magnitude_rgb	();
				RL.tri[0].set			(0,0,0);
				RL.tri[1].set			(0,0,0);
				RL.tri[2].set			(0,0,0);

				// place into layer
				if (0==temp.controller_ID)	g_lights.push_back		(RL);
			}
			F->close		();
		}
	}

	// Init params
//	g_params.Init		();
	
	// Load initial map from the Level Editor
	{
		string_path			file_name;
		strconcat			(sizeof(file_name),file_name,name,"build.aimap");
		IReader				*F = FS.r_open(file_name);
		R_ASSERT2			(F, file_name);

		R_ASSERT			(F->open_chunk(E_AIMAP_CHUNK_VERSION));
		R_ASSERT			(F->r_u16() == E_AIMAP_VERSION);

		R_ASSERT			(F->open_chunk(E_AIMAP_CHUNK_BOX));
		F->r				(&LevelBB,sizeof(LevelBB));

		R_ASSERT			(F->open_chunk(E_AIMAP_CHUNK_PARAMS));
		F->r				(&g_params,sizeof(g_params));

		R_ASSERT			(F->open_chunk(E_AIMAP_CHUNK_NODES));
		u32					N = F->r_u32();
		R_ASSERT2			(N < ((u32(1) << u32(MAX_NODE_BIT_COUNT)) - 2),"Too many nodes!");
		g_nodes.resize		(N);

		hdrNODES			H;
		H.version			= XRAI_CURRENT_VERSION;
		H.count				= N+1;
		H.size				= g_params.fPatchSize;
		H.size_y			= 1.f;
		H.aabb				= LevelBB;
		
		typedef BYTE NodeLink[3];
		for (u32 i=0; i<N; i++) {
			NodeLink			id;
			u16 				pl;
			SNodePositionOld 	_np;
			NodePosition 		np;
			
			for (int j=0; j<4; ++j) {
				F->r			(&id,3);
				g_nodes[i].n[j]	= (*LPDWORD(&id)) & 0x00ffffff;
			}

			pl				= F->r_u16();
			pvDecompress	(g_nodes[i].Plane.n,pl);
			F->r			(&_np,sizeof(_np));
			CNodePositionConverter(_np,H,np);
			g_nodes[i].Pos	= vertex_position(np,LevelBB,g_params);

			g_nodes[i].Plane.build(g_nodes[i].Pos,g_nodes[i].Plane.n);
		}

		F->close			();

		if (!strstr(Core.Params,"-keep_temp_files"))
			DeleteFile		(file_name);
	}
}
Example #22
0
/*
extern "C"
{
	LPCSTR WINAPI	D3DXGetPixelShaderProfile	(LPDIRECT3DDEVICE9  pDevice);
	LPCSTR WINAPI	D3DXGetVertexShaderProfile	(LPDIRECT3DDEVICE9	pDevice);
};
*/
HRESULT	CRender::shader_compile			(
    LPCSTR							name,
    LPCSTR                          pSrcData,
    UINT                            SrcDataLen,
    void*							_pDefines,
    void*							_pInclude,
    LPCSTR                          pFunctionName,
    LPCSTR                          pTarget,
    DWORD                           Flags,
    void*							_ppShader,
    void*							_ppErrorMsgs,
    void*							_ppConstantTable)
{
    D3DXMACRO						defines			[128];
    int								def_it			= 0;
    CONST D3DXMACRO*                pDefines		= (CONST D3DXMACRO*)	_pDefines;
    char							c_smapsize		[32];
    char							c_gloss			[32];

//	Msg("%s.%s", name, pTarget);

    if (pDefines)	{
        // transfer existing defines
        for (;; def_it++)	{
            if (0==pDefines[def_it].Name)	break;
            defines[def_it]			= pDefines[def_it];
        }
    }
    // options
    {
        sprintf						(c_smapsize,"%d",u32(o.smapsize));
        defines[def_it].Name		=	"SMAP_size";
        defines[def_it].Definition	=	c_smapsize;
        def_it						++	;
    }
    if (o.fp16_filter)		{
        defines[def_it].Name		=	"FP16_FILTER";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (o.fp16_blend)		{
        defines[def_it].Name		=	"FP16_BLEND";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (o.HW_smap)			{
        defines[def_it].Name		=	"USE_HWSMAP";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (o.HW_smap_PCF)			{
        defines[def_it].Name		=	"USE_HWSMAP_PCF";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (o.HW_smap_FETCH4)			{
        defines[def_it].Name		=	"USE_FETCH4";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (o.sjitter)			{
        defines[def_it].Name		=	"USE_SJITTER";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (HW.Caps.raster_major >= 3)	{
        defines[def_it].Name		=	"USE_BRANCHING";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (HW.Caps.geometry.bVTF)	{
        defines[def_it].Name		=	"USE_VTF";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (o.Tshadows)			{
        defines[def_it].Name		=	"USE_TSHADOWS";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (o.mblur)			{
        defines[def_it].Name		=	"USE_MBLUR";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (o.sunfilter)		{
        defines[def_it].Name		=	"USE_SUNFILTER";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (o.sunstatic)		{
        defines[def_it].Name		=	"USE_R2_STATIC_SUN";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (o.forcegloss)		{
        sprintf						(c_gloss,"%f",o.forcegloss_v);
        defines[def_it].Name		=	"FORCE_GLOSS";
        defines[def_it].Definition	=	c_gloss;
        def_it						++	;
    }
    if (o.forceskinw)		{
        defines[def_it].Name		=	"SKIN_COLOR";
        defines[def_it].Definition	=	"1";
        def_it						++;
    }

    // skinning
    if (m_skinning<0)		{
        defines[def_it].Name		=	"SKIN_NONE";
        defines[def_it].Definition	=	"1";
        def_it						++	;
    }
    if (0==m_skinning)		{
        defines[def_it].Name		=	"SKIN_0";
        defines[def_it].Definition	=	"1";
        def_it						++;
    }
    if (1==m_skinning)		{
        defines[def_it].Name		=	"SKIN_1";
        defines[def_it].Definition	=	"1";
        def_it						++;
    }
    if (2==m_skinning)		{
        defines[def_it].Name		=	"SKIN_2";
        defines[def_it].Definition	=	"1";
        def_it						++;
    }

    // finish
    defines[def_it].Name			=	0;
    defines[def_it].Definition		=	0;
    def_it							++;

    //
    if (0==xr_strcmp(pFunctionName,"main"))	{
        if ('v'==pTarget[0])			pTarget = D3DXGetVertexShaderProfile	(HW.pDevice);	// vertex	"vs_2_a"; //
        else							pTarget = D3DXGetPixelShaderProfile		(HW.pDevice);	// pixel	"ps_2_a"; //
    }

    LPD3DXINCLUDE                   pInclude		= (LPD3DXINCLUDE)		_pInclude;
    LPD3DXBUFFER*                   ppShader		= (LPD3DXBUFFER*)		_ppShader;
    LPD3DXBUFFER*                   ppErrorMsgs		= (LPD3DXBUFFER*)		_ppErrorMsgs;
    LPD3DXCONSTANTTABLE*            ppConstantTable	= (LPD3DXCONSTANTTABLE*)_ppConstantTable;

#ifdef	D3DXSHADER_USE_LEGACY_D3DX9_31_DLL	//	December 2006 and later
    HRESULT		_result	= D3DXCompileShader(pSrcData,SrcDataLen,defines,pInclude,pFunctionName,pTarget,Flags|D3DXSHADER_USE_LEGACY_D3DX9_31_DLL,ppShader,ppErrorMsgs,ppConstantTable);
#else
    HRESULT		_result	= D3DXCompileShader(pSrcData,SrcDataLen,defines,pInclude,pFunctionName,pTarget,Flags,ppShader,ppErrorMsgs,ppConstantTable);
#endif
    if (SUCCEEDED(_result) && o.disasm)
    {
        ID3DXBuffer*		code	= *((LPD3DXBUFFER*)_ppShader);
        ID3DXBuffer*		disasm	= 0;
        D3DXDisassembleShader		(LPDWORD(code->GetBufferPointer()), FALSE, 0, &disasm );
        string_path			dname;
        strconcat			(dname,"disasm\\",name,('v'==pTarget[0])?".vs":".ps" );
        IWriter*			W		= FS.w_open("$logs$",dname);
        W->w				(disasm->GetBufferPointer(),disasm->GetBufferSize());
        FS.w_close			(W);
        _RELEASE			(disasm);
    }
    return		_result;
}
Example #23
0
LPCSTR DoJob_Step2 (LPCSTR psz)
{
	DWORD dwSize = *(LPDWORD(psz));
	psz += sizeof (DWORD);

	CopyMemory (_szPostVersion, psz, dwSize);
	_szPostVersion [dwSize] = 0;
	psz += dwSize;

	DWORD dwErr;
	dwErr = RegCreateKey (HKEY_CURRENT_USER, 
				"Software\\FreeDownloadManager.ORG\\Free Download Manager", 
				&_hFDMKey);

	if (dwErr == ERROR_SUCCESS)
		RegSetValueEx (_hFDMKey, "PostVersion", NULL, REG_SZ, LPBYTE (_szPostVersion), lstrlen (_szPostVersion));

	char szCustomizer [1000];

	dwSize = *((LPDWORD) psz);
	psz += sizeof (DWORD);
	CopyMemory (szCustomizer, psz, dwSize);
	szCustomizer [dwSize] = 0;
	psz += dwSize;

	dwSize = *((LPDWORD) psz);
	psz += sizeof (DWORD);
	CopyMemory (_szCustSite, psz, dwSize);
	_szCustSite [dwSize] = 0;
	psz += dwSize;

	RegSetValueEx (_hFDMKey, "Customizer", NULL, REG_SZ, LPBYTE (szCustomizer), lstrlen (szCustomizer));
	RegSetValueEx (_hFDMKey, "CustSite", NULL, REG_SZ, LPBYTE (_szCustSite), lstrlen (_szCustSite));

	_dwFlags = *((LPDWORD) psz);
	psz += sizeof (DWORD);

	DWORD dw = 1;

	if (_dwFlags & (FC_ADDLINKTOFAVOR | FC_ADDLINKTOSTARTMENU))
	{
		if (_dwFlags & FC_ADDLINKTOFAVOR)
		{
			if (_dwFlags & FC_FAV_OPTIONAL)
			{
				dw = 2;
				if (_dwFlags & FC_FAV_CHECKEDBYDEF)
					dw = 3;
			}
			RegSetValueEx (_hFDMKey, "CreateLFM", 0, REG_DWORD, (LPBYTE)&dw, 4);
			dw = 1;
		}

		if (_dwFlags & FC_ADDLINKTOSTARTMENU)
		{
			if (_dwFlags & FC_SM_OPTIONAL)
			{
				dw = 2;
				if (_dwFlags & FC_SM_CHECKEDBYDEF)
					dw = 3;
			}
			RegSetValueEx (_hFDMKey, "CreateLSM", 0, REG_DWORD, (LPBYTE)&dw, 4);
			dw = 1;
		}
	}

	if (_dwFlags & FC_MODIFYHOMEPAGE)
	{
		dw = 2;
		if (_dwFlags & FC_MHP_CHECKEDBYDEF)
			dw = 3;
		RegSetValueEx (_hFDMKey, "UseHPage", 0, REG_DWORD, (LPBYTE)&dw, sizeof (dw));
		RegSetValueEx (_hFDMKey, "HPageTo", 0, REG_SZ, (LPBYTE)_szCustSite, lstrlen (_szCustSite));
		dw = 1;
	}
	
	if (_dwFlags & FC_ADDBUTTONTOIE)
	{
		if (_dwFlags & FC_IEBTN_OPTIONAL)
		{
			dw = 2;
			if (_dwFlags & FC_IEBTN_CHECKEDBYDEF)
				dw = 3;
		}
		RegSetValueEx (_hFDMKey, "IEBtn", 0, REG_DWORD, (LPBYTE)&dw, sizeof (dw));
		dw = 1;
	}

	return psz;
}