예제 #1
1
파일: main.cpp 프로젝트: dibery/Dorm-IP
void setxp()
{
    int a = ipa, b = ipb;
    char cmd[ 1024 ];
    STARTUPINFO si;
    ZeroMemory(&si, sizeof(si));
    PROCESS_INFORMATION pi;
    ZeroMemory(&pi, sizeof(pi));
    sprintf( cmd, "netsh interface ip set address \"區域連線\" static 140.119.%d.%d 255.255.255.0 140.119.%d.254 1", a, b, a );
    CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
    WaitForSingleObject(pi.hProcess, INFINITE);
    //cleanup
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    sprintf( cmd, "netsh interface ip set dns \"區域連線\" static 140.119.1.110" );
    CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
    WaitForSingleObject(pi.hProcess, INFINITE);
    //cleanup
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    sprintf( cmd, "netsh interface ip add dns \"區域連線\" 140.119.252.12" );
    CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
    WaitForSingleObject(pi.hProcess, INFINITE);
    //cleanup
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
}
예제 #2
0
void ipcPrepareRequests(int ipcPacketSize, THeaderIPC *pipch, DWORD fRequests)
{
	// some fields may already have values like the event object name to open
	pipch->cbSize = sizeof(THeaderIPC);
	pipch->dwVersion = PLUGIN_MAKE_VERSION(2, 0, 1, 2);
	pipch->dwFlags = 0;
	pipch->pServerBaseAddress = NULL;
	pipch->pClientBaseAddress = pipch;
	pipch->fRequests = fRequests;
	pipch->Slots = 0;
	pipch->IconsBegin = NULL;
	pipch->ContactsBegin = NULL;
	pipch->GroupsBegin = NULL;
	pipch->NewIconsBegin = NULL;
	pipch->DataSize = ipcPacketSize - pipch->cbSize;
	// the server side will adjust these pointers as soon as it opens
	// the mapped file to it's base address, these are set 'ere because ipcAlloc()
	// maybe used on the client side and are translated by the server side.
	// ipcAlloc() is used on the client side when transferring filenames
	// to the ST thread.
	pipch->DataPtr = (TSlotIPC*)(LPSTR(pipch) + sizeof(THeaderIPC));
	pipch->DataPtrEnd = (TSlotIPC*)(LPSTR(pipch->DataPtr) + pipch->DataSize);
	pipch->DataFramePtr = pipch->DataPtr;
	// fill the data area
	memset(pipch->DataPtr,0 , pipch->DataSize);
}
예제 #3
0
파일: main.cpp 프로젝트: dibery/Dorm-IP
void set8()
{
    STARTUPINFO si;
    ZeroMemory(&si, sizeof(si));
    PROCESS_INFORMATION pi;
    ZeroMemory(&pi, sizeof(pi));
    int a = ipa, b = ipb;
    char cmd[ 1024 ];
    sprintf( cmd, "netsh interface ipv4 set address name=\"乙太網路\" source=static address=140.119.%d.%d mask=255.255.255.0 gateway=140.119.%d.254", a, b, a );
    CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
    WaitForSingleObject(pi.hProcess, INFINITE);
    //cleanup
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    sprintf( cmd, "netsh interface ipv4 add dnsserver name=\"乙太網路\" address=140.119.1.110 index=1" );
    CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
    WaitForSingleObject(pi.hProcess, INFINITE);
    //cleanup
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    sprintf( cmd, "netsh interface ipv4 add dnsserver name=\"乙太網路\" address=140.119.252.12 index=2" );
    CreateProcess(NULL, LPSTR(cmd), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
    WaitForSingleObject(pi.hProcess, INFINITE);
    //cleanup
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
}
예제 #4
0
void CShortcut::FormatKeyLabel(VirtualKeyName* pVirtualKeyNames,BYTE bKey,BYTE bModifiers,BOOL bScancode,CStringW& str)
{
	if (bKey==0)
	{
		str.LoadString(IDS_SHORTCUTNONE);
		return;
	}


	// Formatting modifiers
	if (bModifiers&MOD_WIN)
		str.LoadString(IDS_SHORTCUTMODEXT);
	else
		str.Empty();
	if (bModifiers&MOD_CONTROL)
		str.AddString(IDS_SHORTCUTMODCTRL);
	if (bModifiers&MOD_ALT)
		str.AddString(IDS_SHORTCUTMODALT);
	if (bModifiers&MOD_SHIFT)
		str.AddString(IDS_SHORTCUTMODSHIFT);
	
	if (bScancode)
	{
		CStringW str2;
		str2.Format(IDS_SHORTCUTSCANCODE,(int)bKey);
		str << str2;
		return;
	}

	int i;
	for (i=0;pVirtualKeyNames[i].bKey!=0 && pVirtualKeyNames[i].bKey!=bKey;i++);
	if (pVirtualKeyNames[i].iFriendlyNameId!=0)
	{
		str.AddString(pVirtualKeyNames[i].iFriendlyNameId);
		return;
	}

	BYTE pKeyState[256];
	ZeroMemory(pKeyState,256);

	WORD wChar;
	int nRet=ToAscii(bKey,0,pKeyState,&wChar,0);
	if (nRet==1)
	{
		MakeUpper((LPSTR)&wChar,1);
		str << char(wChar);
	} 
	else if (nRet==2)
	{
		MakeUpper((LPSTR)&wChar,2);
		str << (LPSTR(&wChar))[0] << (LPSTR(&wChar))[0];
	}
	else if (pVirtualKeyNames[i].pName!=NULL)
		str << pVirtualKeyNames[i].pName;
	else
		str << (int) bKey;
}
예제 #5
0
void DecideMenuItemInfo(TSlotIPC *pct, TGroupNode *pg, MENUITEMINFOA &mii, TEnumData *lParam)
{
	mii.wID = lParam->idCmdFirst;
	lParam->idCmdFirst++;
	// get the heap object
	HANDLE hDllHeap = lParam->Self->hDllHeap;
	TMenuDrawInfo *psd = (TMenuDrawInfo*)HeapAlloc(hDllHeap, 0, sizeof(TMenuDrawInfo));
	if (pct != NULL) {
		psd->cch = pct->cbStrSection - 1; // no null;
		psd->szText = (char*)HeapAlloc(hDllHeap, 0, pct->cbStrSection);
		lstrcpyA(psd->szText, (char*)pct + sizeof(TSlotIPC));
		psd->hContact = pct->hContact;
		psd->fTypes = dtContact;
		// find the protocol icon array to use && which status
		UINT c = lParam->Self->ProtoIconsCount;
		TSlotProtoIcons *pp = lParam->Self->ProtoIcons;
		psd->hStatusIcon = 0;
		while (c > 0) {
			c--;
			if (pp[c].hProto == pct->hProto && pp[c].pid == lParam->pid) {
				psd->hStatusIcon = pp[c].hIcons[pct->Status - ID_STATUS_OFFLINE];
				psd->hStatusBitmap = pp[c].hBitmaps[pct->Status - ID_STATUS_OFFLINE];
				break;
			}
		} // while
		psd->pid = lParam->pid;
	}
	else if (pg != NULL) {
		// store the given ID
		pg->hMenuGroupID = mii.wID;
		// steal the pointer from the group node it should be on the heap
		psd->cch = pg->cchGroup;
		psd->szText = pg->szGroup;
		psd->fTypes = dtGroup;
	} // if
	psd->wID = mii.wID;
	psd->szProfile = NULL;
	// store
	mii.dwItemData = UINT_PTR(psd);

	if (lParam->bOwnerDrawSupported && lParam->bShouldOwnerDraw) {
		mii.fType = MFT_OWNERDRAW;
		mii.dwTypeData = (LPSTR)psd;
	}
	else {
		// normal menu
		mii.fType = MFT_STRING;
		if (pct != NULL)
			mii.dwTypeData = LPSTR(pct) + sizeof(TSlotIPC);
		else
			mii.dwTypeData = pg->szGroup;

		// For Vista + let the system draw the theme && icons, pct = contact associated data
		if (bIsVistaPlus && pct != NULL && psd != NULL) {
			mii.fMask = MIIM_BITMAP | MIIM_FTYPE | MIIM_ID | MIIM_DATA | MIIM_STRING;
			// BuildSkinIcons() built an array of bitmaps which we can use here
			mii.hbmpItem = psd->hStatusBitmap;
		}
	}
}
예제 #6
0
파일: XMMTCtl.cpp 프로젝트: ja7ude/XMMT
BOOL CXMMTCtrl::PostMmttyMessageAsString(short nIndex, long wParam, LPCTSTR pStr) 
{
	int r = FALSE;
	CCSocket *pSocket = GetSocket(nIndex);
	if( pSocket ){
		int len = sizeof(COMMSG) + lstrlen(pStr) + 1;
		LPBYTE pb = new BYTE[len];
		COMMSG *pCom = (COMMSG *)pb;
		pCom->m_wParam = wParam;
		pCom->m_lParam = 0;
		// 文字列の実体をCOMMSGのすぐ後ろにコピーします。
#ifdef _UNICODE
		LPSTR p = LPSTR(pb + sizeof(COMMSG));
		while(*pStr){
			*p++ = BYTE(*pStr++);
		}
		*p = 0;
#else
		lstrcpy(LPTSTR(pb + sizeof(COMMSG)), pStr);
#endif

		CCustomSession cs(COM_MESSAGE, pb, len);
		delete pb;
		int size;
		CUSTOMHEAD *pHeader = cs.GetHeader(size);
		r = SendBuf(pSocket, pHeader, size);
	}
	return r;
}
static BOOL CALLBACK Dlg_Warning(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
{
   switch(Message)
   {
      case WM_INITDIALOG:
             CenterDlg(hDlg, -80);                           //Центрирование окна диалога в главном окне
             SetWindowText(hDlg, (Lan+36)->msg);             //Вывели новый заголовок
             OutNameDlg(hDlg, IDC_STATICTEXT1, LPSTR(lParam));     //Усечение имени файла
             SetDlgItemText(hDlg, IDC_STATICTEXT2, (Lan+65)->msg);
             SetDlgItemText(hDlg, IDC_REWRITE, (Lan+66)->msg);
             SetDlgItemText(hDlg, IDC_NEW, (Lan+67)->msg);
             SetDlgItemText(hDlg, IDCANCEL, (Lan+68)->msg);
             return TRUE;
      case WM_CTLCOLORSTATIC:
             if(GetDlgCtrlID(HWND(lParam)) == IDC_STATICTEXT2)
             {  SetTextColor((HDC)wParam, RGB(255, 0, 0));
                SetBkColor((HDC)wParam, FonLTGRAY);
                return (BOOL)FonBrush;
             }
             return TRUE;
      case WM_COMMAND:
           switch(LOWORD(wParam))
           {  case IDC_REWRITE:
              case IDC_NEW:
              case IDCANCEL:    EndDialog(hDlg, LOWORD(wParam));  //Вернули один из трех кодов
                                return TRUE;
           }
           break;
   }
   return FALSE;
}
예제 #8
0
MotionID CKinematicsAnimated::ID_Motion(LPCSTR  N, u16 slot)
{
	MotionID 				motion_ID;
    if (slot<MAX_ANIM_SLOT){
        shared_motions* s_mots	= &m_Motions[slot].motions;
        // find in cycles
        accel_map::iterator I 	= s_mots->cycle()->find(LPSTR(N));
        if (I!=s_mots->cycle()->end())	motion_ID.set(slot,I->second);
        if (!motion_ID.valid()){
            // find in fx's
            accel_map::iterator I 	= s_mots->fx()->find(LPSTR(N));
            if (I!=s_mots->fx()->end())	motion_ID.set(slot,I->second);
        }
    }
    return motion_ID;
}
예제 #9
0
/*********************************************************************
* 函数名称:int Write_Log_Text(LPLOG_DATA lpLogData)
* 说明:写日志内容
* 调用者:Write_Log
* 输入参数:
* LPLOG_DATA lpLogData --日志内容结构体量
* 输出参数:
* 无
* 返回值:
* int -- LOG_FAILED: 失败
*      -- LOG_SUCCESS: 成功
*********************************************************************/
int CWriteLog::Write_Log_Text(LPLOG_DATA lpLogData)
{
	TCHAR szFilePath[MAX_FILE_PATH];
	TCHAR szFileName[MAX_LOG_FILE_NAME_LEN];
	FILE *pFile = NULL;
	TCHAR szLogText[MAX_LOGTEXT_LEN];
	memset(szFilePath, 0, MAX_FILE_PATH);
	memset(szFileName, 0, MAX_LOG_FILE_NAME_LEN);
	memset(szLogText, 0, MAX_LOGTEXT_LEN);
	GetLogPath(szFilePath);
	GetLogFileName(lpLogData->iType, szFilePath, szFileName);
	pFile = _tfopen(szFileName, _T("a+"));
	if(NULL == pFile)
	{
		return LOG_FAILED;
	}
	_stprintf(szLogText, _T("%s[%s %s] %s   -----  [%s][%d]\n"), lpLogData->strModel, lpLogData->strDate, lpLogData->strTime, lpLogData->strText, lpLogData->strFile, lpLogData->iLine);

	//fwrite(szLogText, 1, _tcslen(szLogText), pFile);
	//acsii 的方式, unicode写入乱码
	int len = _tcslen(szLogText);
	char* pchBuffer = new char[len * 2 + 1];
	int a = WideCharToMultiByte(CP_ACP, NULL, (LPCWCH)szLogText, -1, LPSTR(pchBuffer), len*2 + 1, NULL, FALSE);//Unicode转换为ANSI,a的值包括了字符串最后的0
	fwrite(pchBuffer, 1, a - 1, pFile);
	delete[] pchBuffer;
	pchBuffer = NULL;

	fclose(pFile);
	return LOG_SUCCESS;
}
예제 #10
0
/**
 * @brief Convert a Windows style path to a file name into an Unix style one.
 *
 * @param filename pointer to the file path to be converted
 *
 * @return pointer to the converted file path
 */
static char *unix_name (char *filename)
{
    static char *unix_filename;
    LPSTR (*CDECL wine_get_unix_file_name_ptr)(LPCWSTR);
    int wchar_conv;

    if (*filename && (filename[1] == ':'))
    {
        wine_get_unix_file_name_ptr = (void *) GetProcAddress(GetModuleHandleA("KERNEL32"), "wine_get_unix_file_name");
        wchar_conv = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0);

        if (wine_get_unix_file_name_ptr && wchar_conv)
        {
            WCHAR *ntpath;
            char *unix_name;

            ntpath = HeapAlloc(GetProcessHeap(), 0, sizeof(*ntpath) * (wchar_conv + 1));
            MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, ntpath, wchar_conv);
            unix_name = wine_get_unix_file_name_ptr(ntpath);
            setdup(&unix_filename, unix_name);
            filename = unix_filename;
            HeapFree(GetProcessHeap(), 0, unix_name);
            HeapFree(GetProcessHeap(), 0, ntpath);
        }
    }

    return filename;
}
예제 #11
0
void TextIndex::make_index(LPCSTR sourceTxt)
{
	clear();
	strcpy_s(fileName, 256, sourceTxt);
	if(!strchr(fileName, '.')){
		strcat_s(fileName, 256, ".txt"); // append extension if missing
	}
	Filemap txtFileMap;
	LPVOID txtAddrBase = txtFileMap.open_read(fileName, FALSE);
	if(txtAddrBase){
		LPVOID seekAddr = txtAddrBase;
		LPVOID eofAddr = LPVOID(DWORD(txtAddrBase) + txtFileMap.getSize());
		Heap::init(0x8000); // maximum amount of memory per section index
		while(seekAddr < eofAddr){
			LPVOID foundAddr = memchr(seekAddr, '\n', DWORD(eofAddr) - DWORD(seekAddr));
			if(!foundAddr){
				break; // invalid file, no newlines
			}
			char parseBuffer[512]; // maximum line length
			memcpy_s(parseBuffer, 512, seekAddr, DWORD(foundAddr) - DWORD(seekAddr) + 1);
			kill_newline(parseBuffer);
			trim_spaces(parseBuffer);
			if(parseBuffer[0] == '#' && isupper(parseBuffer[1])){
				DWORD len = strlen(&parseBuffer[1]) + 1;
				LPVOID storeAddr = Heap::get(len + 4); // section name + address
				*(LPDWORD)storeAddr = DWORD(seekAddr) - DWORD(txtAddrBase); // file offset
				strcpy_s(LPSTR(storeAddr) + 4, len, &parseBuffer[1]);
				sectionCount++;
			}
			seekAddr = LPVOID(DWORD(foundAddr) + 1);
		}
		Heap::squeeze();
	}
}
예제 #12
0
//选出一个权重,次数,分类,特征
map <string, map<string, Feature>> Model::getallfeature()
{
	auto cats=this->catcounts();
	auto itcat = cats.begin();
	map <string, map<string, Feature>> result;
	while (itcat != cats.end())
	{
		string query = "select feature,weight,count from nfc where cat='"+itcat->first+"'";
		m_pRecordset = this->GetRecordSet(query.c_str());
		map<string, Feature> tempacat;
		while (!m_pRecordset->adoEOF)
		{
			Feature fea;
			string feature = LPSTR(_bstr_t(m_pRecordset->GetCollect("feature")));
			double weight = m_pRecordset->GetCollect("weight");
			int count = m_pRecordset->GetCollect("count");
			fea.weight = weight;
			fea.count = count;
			tempacat.insert(make_pair(feature, fea));
			m_pRecordset->MoveNext();
		}
		result.insert(make_pair(itcat->first,tempacat));
		++itcat;
	}
	return result;
}
예제 #13
0
bool ShowOpenFileDialog(char* FileName, int FileNameLength, char* filter)
// Open a dialog for selecting a file and returns true if succeeded with the name of the file in the preallocated buffer <FileName>
{
    OPENFILENAMEA ofn ;

    ZeroMemory(&ofn, sizeof(ofn));

    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = GetActiveWindow(); 
    ofn.lpstrDefExt = 0;
    FileName[0] = '\0';
	ofn.lpstrFile = FileName;
    ofn.nMaxFile = FileNameLength;
    ofn.lpstrFilter = filter; 
    ofn.nFilterIndex = 1;
    char strAux[MAX_PATH];
	GetCurrentDirectoryA(MAX_PATH, strAux);
	ofn.lpstrInitialDir = strAux;
    ofn.lpstrTitle = LPSTR("Open File");
    ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ENABLESIZING;

    GetOpenFileNameA(&ofn);

    if (strlen(ofn.lpstrFile) == 0) return false;
    return true;
} // ShowOpenFileDialog
예제 #14
0
BYTE* CStdCrypt::encodeBuffer(const void *src, size_t cbLen, size_t *cbResultLen)
{
	if (cbResultLen)
		*cbResultLen = 0;

	if (!m_valid || src == NULL || cbLen >= 0xFFFE)
		return NULL;

	BYTE *tmpBuf = (BYTE*)_alloca(cbLen + 2);
	*(PWORD)tmpBuf = (WORD)cbLen;
	memcpy(tmpBuf + 2, src, cbLen);
	cbLen += 2;
	size_t rest = cbLen % BLOCK_SIZE;
	if (rest)
		cbLen += BLOCK_SIZE - rest;

	BYTE *result = (BYTE*)mir_alloc(cbLen);
	m_aes.ResetChain();
	if (m_aes.Encrypt(tmpBuf, LPSTR(result), cbLen)) {
		mir_free(result);
		return NULL;
	}

	if (cbResultLen)
		*cbResultLen = cbLen;
	return result;
}
예제 #15
0
bool NetChannel::AsynRecv(PBYTE pData, long lDataSize)
{
	if( pData == NULL || lDataSize <= 0)
		return false;

	MYOVERLAPPED& olp = m_OLPRecv;

	WSABUF wsabuf;
	wsabuf.buf = LPSTR( pData );
	wsabuf.len = lDataSize;

	DWORD dwTransed = 0;
	DWORD dwFlags = 0;

	if ( WSARecv( m_socket.GetSocket(), &wsabuf, 1, &dwTransed, &dwFlags, (LPWSAOVERLAPPED)&olp, NULL ) != 0)
	{
		int32 nError = WSAGetLastError();
		if( nError != WSA_IO_PENDING )
		{
			OnExitReceiving();
			return false;
		}
	}

	m_pMgr->BytesRecv().Add(lDataSize);
	return true;
}
예제 #16
0
CTexture*	CResourceManager::_FindTexture(LPCSTR Name)
{
	// copypaste from _CreateTexture
	if (0 == xr_strcmp(Name, "null"))	return 0;
	R_ASSERT(Name && Name[0]);
	string_path		filename;
	strcpy_s(filename, Name); //. andy if (strext(Name)) *strext(Name)=0;
	fix_texture_name(filename);

	LPSTR N = LPSTR(filename);
	char *ch = strstr(N, "*");
	if (NULL == ch) // no wildcard?
	{
		map_TextureIt I = m_textures.find(N);
		if (I != m_textures.end())	return	I->second;
	}
	else
	{
		// alpet: test for wildcard matching
		ch[0] = 0; // remove *

		for (map_TextureIt t = m_textures.begin(); t != m_textures.end(); t++)
		if (strstr(t->second->cName.c_str(), N))
			return t->second;
	}

	return NULL;
}
예제 #17
0
static LPSTR GetErrorText(HRESULT hr)
{
	// Answer some suitable text for the last system error
	LPSTR buf;
	::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
		0, hr, 0, LPSTR(&buf), 0, 0);
	return buf;
}
예제 #18
0
 WaveBuffer()
     : isUsed(false)
 {
     InitializeCriticalSection(critSect);
     ZeroMemory(&header, sizeof(WAVEHDR));
     header.lpData = LPSTR(samples);
     header.dwBufferLength = BufferSize * sizeof(short);
 }
예제 #19
0
void ipcGetSkinIcons(THeaderIPC *ipch)
{
	TSlotProtoIcons spi;
	char szTmp[64];

	int protoCount;
	PROTOACCOUNT **pp;
	if ( CallService(MS_PROTO_ENUMACCOUNTS, WPARAM(&protoCount), LPARAM(&pp)) == 0 && protoCount != 0) {
		spi.pid = GetCurrentProcessId();
		while (protoCount > 0) {
			PROTOACCOUNT *pa = *pp;
			lstrcpyA(szTmp, pa->szModuleName);
			lstrcatA(szTmp, PS_GETCAPS);
			DWORD dwCaps = CallService(szTmp, PFLAGNUM_1, 0);
			if (dwCaps & PF1_FILESEND) {
				TSlotIPC *pct = ipcAlloc(ipch, sizeof(TSlotProtoIcons));
				if (pct != NULL) {
					// capture all the icons!
					spi.hProto = murmur_hash(pa->szModuleName);
					for (int j = 0; j <= 10; j++)
						spi.hIcons[j] = LoadSkinnedProtoIcon(pa->szModuleName, ID_STATUS_OFFLINE + j);

					pct->fType = REQUEST_NEWICONS;
					memcpy(LPSTR(pct) + sizeof(TSlotIPC), &spi, sizeof(TSlotProtoIcons));
					if (ipch->NewIconsBegin == NULL)
						ipch->NewIconsBegin = pct;
				}
			}
			pp++;
			protoCount--;
		}
	}

	// add Miranda icon
	TSlotIPC *pct = ipcAlloc(ipch, sizeof(TSlotProtoIcons));
	if (pct != NULL) {
		ZeroMemory(&spi.hIcons, sizeof(spi.hIcons));
		spi.hProto = 0; // no protocol
		spi.hIcons[0] = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
		pct->fType = REQUEST_NEWICONS;
		memcpy(LPSTR(pct) + sizeof(TSlotIPC), &spi, sizeof(TSlotProtoIcons));
		if (ipch->NewIconsBegin == NULL)
			ipch->NewIconsBegin = pct;
	}
}
예제 #20
0
IBlender* CResourceManager::_FindBlender		(LPCSTR Name)
{
	if (!(Name && Name[0])) return 0;

	LPSTR N = LPSTR(Name);
	map_Blender::iterator I = m_blenders.find	(N);
	if (I==m_blenders.end())	return 0;
	else						return I->second;
}
예제 #21
0
int  main (int argc, char *argv[])
{
	int ret= ERR_OK;

  if(argc < 2) ret= ERR_ARG;
  else {
    if(!strcmp(argv[ARG_CMD], CMD_ADD)) {
      if(argc != 4) ret= ERR_ARG;
      else {
        char buf[CRED_MAX_CREDENTIAL_BLOB_SIZE+1];
        int cnt;
        cnt= _read(0, buf, sizeof(buf));
        if(cnt == -1) ret= ERR_RD;
        else if(cnt == sizeof(buf)) ret= ERR_TOOLONG;
        else {
          CREDENTIAL cred = {0};
          cred.Type = CRED_TYPE_GENERIC;
          cred.TargetName = LPSTR(argv[ARG_APP]);
          cred.CredentialBlobSize= cnt;
          cred.CredentialBlob= (LPBYTE)buf;
          cred.Persist= CRED_PERSIST_LOCAL_MACHINE;
          cred.UserName= LPSTR(argv[ARG_USER]);
          ret= ::CredWrite (&cred, 0)? ERR_OK:ERR_CRED;
        }
      }
    } else if(argc != 3) ret= ERR_ARG;
    else if(!strcmp(argv[ARG_CMD], CMD_GETP) || !strcmp(argv[ARG_CMD], CMD_GETN)) {
      PCREDENTIAL pcred;
      if(::CredRead (LPSTR(argv[ARG_APP]), CRED_TYPE_GENERIC, 0, &pcred)) {
        if(!strcmp(argv[ARG_CMD], CMD_GETP)) {
          if(_write(1, pcred->CredentialBlob,pcred->CredentialBlobSize) == -1) ret= ERR_WR;

        } else {
          if(_write(1, pcred->UserName, strlen(pcred->UserName)) == -1) ret= ERR_WR;
        }
        // must free memory allocated by CredRead()!
        ::CredFree (pcred);
      } else ret= ERR_CRED;
    } else if(!strcmp(argv[ARG_CMD], CMD_RM)) {
      if(::CredDelete (LPCSTR(argv[ARG_APP]), CRED_TYPE_GENERIC, 0) == false) ret= ERR_CRED;
    } else ret= ERR_CMD;
  }
  return(_return(ret));
}
예제 #22
0
void CQuickBuildString::InitAssign(LPCSTR sz, int iLen)
{
	m_iLength = iLen;
	m_iAllocLength = m_iLength + 1;
	m_szContent = LPSTR(Alloc(m_iAllocLength));
	CopyMemory(m_szContent, sz, iLen);
	m_szContent[iLen] = 0;

	CheckValid();
}
예제 #23
0
void CQuickBuildString::Init()
{
	m_szContent = LPSTR(Alloc(iBlockSize));

	if (m_szContent)
		m_szContent[0] = 0;

	m_iLength		= 0;
	m_iAllocLength	= iBlockSize;
}
예제 #24
0
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
MotionID CKinematicsAnimated::LL_MotionID	(LPCSTR B)
{
	MotionID motion_ID;
	for (int k=int(m_Motions.size())-1; k>=0; --k){
    	shared_motions* s_mots	= &m_Motions[k].motions;
		accel_map::iterator I 	= s_mots->motion_map()->find(LPSTR(B));
    	if (I!=s_mots->motion_map()->end())	{ motion_ID.set(u16(k),I->second); break; }
    }
    return motion_ID;
}
예제 #25
0
bool CProProcess::GetProfileSetting() 
{
	TCHAR pInitFile[512]={0};
	lstrcpy(pInitFile,m_strAppPath);
	lstrcat(pInitFile,_T("ProcessSet.ini"));

	TCHAR pValue[255]={0};
	GetPrivateProfileString(_T("Setting"),_T("Protect"),_T(""),pValue,255,pInitFile); 
	return atoi(LPSTR(pValue)); 
}
예제 #26
0
void	CResourceManager::_DeleteConstant		(const CConstant* C)
{
	if (0==(C->dwFlags&xr_resource_flagged::RF_REGISTERED))	return;
	LPSTR N				= LPSTR				(*C->cName);
	map_Constant::iterator I	= m_constants.find	(N);
	if (I!=m_constants.end())	{
		m_constants.erase(I);
		return;
	}
	Msg	("! ERROR: Failed to find R1-constant-def '%s'",*C->cName);
}
예제 #27
0
void	CResourceManager::_DeleteMatrix		(const CMatrix* M)
{
	if (0==(M->dwFlags&xr_resource_flagged::RF_REGISTERED))	return;
	LPSTR N					= LPSTR		(*M->cName);
	map_Matrix::iterator I	= m_matrices.find	(N);
	if (I!=m_matrices.end())	{
		m_matrices.erase(I);
		return;
	}
	Msg	("! ERROR: Failed to find xform-def '%s'",*M->cName);
}
예제 #28
0
void	CResourceManager::_DeleteRTC		(const CRTC* RT)
{
	if (0==(RT->dwFlags&xr_resource_flagged::RF_REGISTERED))	return;
	LPSTR N				= LPSTR		(*RT->cName);
	map_RTC::iterator I	= m_rtargets_c.find	(N);
	if (I!=m_rtargets_c.end())	{
		m_rtargets_c.erase(I);
		return;
	}
	Msg	("! ERROR: Failed to find render-target '%s'",*RT->cName);
}
예제 #29
0
void	CResourceManager::_DeletePS			(const SPS* ps)
{
	if (0==(ps->dwFlags&xr_resource_flagged::RF_REGISTERED))	return;
	LPSTR N				= LPSTR		(*ps->cName);
	map_PS::iterator I	= m_ps.find	(N);
	if (I!=m_ps.end())	{
		m_ps.erase(I);
		return;
	}
	Msg	("! ERROR: Failed to find compiled pixel-shader '%s'",*ps->cName);
}
예제 #30
0
void	CResourceManager::_DeleteVS			(const SVS* vs)
{
	if (0==(vs->dwFlags&xr_resource_flagged::RF_REGISTERED))	return;
	LPSTR N				= LPSTR		(*vs->cName);
	map_VS::iterator I	= m_vs.find	(N);
	if (I!=m_vs.end())	{
		m_vs.erase(I);
		return;
	}
	Msg	("! ERROR: Failed to find compiled vertex-shader '%s'",*vs->cName);
}