Пример #1
0
BOOL WINAPI Hook_RegisterHotKey(HWND hWnd, INT id, UINT fsModifiers, UINT vk)
{
	if (IsLogEnabled()) {
		FILE *f;
		::_tfopen_s(&f, g_LogFile.path, _T("a"));
		if (f != NULL) {
			::_ftprintf(f, _T("%d:"), id);
			FLAGSTR(MOD_ALT);
			FLAGSTR(MOD_CONTROL);
			FLAGSTR(MOD_SHIFT);
			FLAGSTR(MOD_WIN);
			if (vk >= 'A' && vk <= 'Z') {
				::_ftprintf(f, _T(" %c\n"), vk);
			} else {
				::_ftprintf(f, _T(" 0x%X\n"), vk);
			}
			::fclose(f);
		}
	}
	
	UINT mods = fsModifiers & MOD_KEYS;
	for (HOPRRE_ENTRY *cur = g_Applied; cur != NULL; cur = cur->pNext) {
		BOOL match_id = (cur->c.id == -1) || (cur->c.id == id);
		BOOL match_mod = (cur->c.fsModifiers == 0xFFFFFFFF) || (cur->c.fsModifiers == mods);
		BOOL match_vk = (cur->c.vk == 0xFFFFFFFF) || (cur->c.vk == vk);
		
		if (IsLogEnabled()) {
			FILE *f;
			::_tfopen_s(&f, g_LogFile.path, _T("a"));
			if (f != NULL) {
				::_ftprintf(
					f,
					_T("%s:%d/%d; %s:%d/%d; %s:%d/%d;\r\n"),
					(match_id ? _T("ID") : _T("id")) ,cur->c.id, id,
					(match_mod ? _T("MOD") : _T("mod")), cur->c.fsModifiers, mods,
					(match_vk ? _T("VK") : _T("vk")), cur->c.vk, vk
				);
				::fclose(f);
			}
		}
		
		if (match_id && match_mod && match_vk) {
			switch (cur->c.dwAction) {
				case PRA_AU_RETURN_FALSE:
					((PFNREGISTERHOTKEY)(PROC) *(g_pRegisterHotKey))(hWnd, id, fsModifiers, vk);
					::UnregisterHotKey(hWnd, id);
				case PRA_IG_RETURN_FALSE:
					return FALSE;
				case PRA_AU_RETURN_TRUE:
					((PFNREGISTERHOTKEY)(PROC) *(g_pRegisterHotKey))(hWnd, id, fsModifiers, vk);
					::UnregisterHotKey(hWnd, id);
				case PRA_IG_RETURN_TRUE:
					return TRUE;
				default:
					return FALSE;
			}
		}
	}
	return ((PFNREGISTERHOTKEY)(PROC) *(g_pRegisterHotKey))(hWnd, id, fsModifiers, vk);
}
Пример #2
0
void
Layer::LogSelf(const char* aPrefix)
{
  if (!IsLogEnabled())
    return;

  nsCAutoString str;
  PrintInfo(str, aPrefix);
  MOZ_LAYERS_LOG(("%s", str.get()));
}
Пример #3
0
void LOG(char *psMsgFmt, ...)
{
int iLen;
char buff[200];
va_list ArgList;
va_start(ArgList, psMsgFmt);
iLen = wvsprintf((LPTSTR)sLogLine, (LPTSTR)psMsgFmt, ArgList);
sprintf(buff,(LPTSTR)psMsgFmt,ArgList);
//MessageBox(NULL,(LPTSTR)sLogLine,"Teade",0);
va_end(ArgList);
if (IsLogEnabled() == TRUE)
  IntLogToFile(sLogLine,iLen);
}
Пример #4
0
void
Layer::LogSelf(const char* aPrefix)
{
  if (!IsLogEnabled())
    return;

  nsAutoCString str;
  PrintInfo(str, aPrefix);
  MOZ_LAYERS_LOG(("%s", str.get()));

  if (mMaskLayer) {
    nsAutoCString pfx(aPrefix);
    pfx += "   \\ MaskLayer ";
    mMaskLayer->LogSelf(pfx.get());
  }
}
Пример #5
0
void
LayerManager::Log(const char* aPrefix)
{
  if (!IsLogEnabled())
    return;

  LogSelf(aPrefix);

  nsCAutoString pfx(aPrefix);
  pfx += "  ";
  if (!mRoot) {
    MOZ_LAYERS_LOG(("%s(null)", pfx.get()));
    return;
  }

  mRoot->Log(pfx.get());
}
Пример #6
0
void
Layer::Log(const char* aPrefix)
{
  if (!IsLogEnabled())
    return;

  LogSelf(aPrefix);

  if (Layer* kid = GetFirstChild()) {
    nsCAutoString pfx(aPrefix);
    pfx += "  ";
    kid->Log(pfx.get());
  }

  if (Layer* next = GetNextSibling())
    next->Log(aPrefix);
}
Пример #7
0
// 適用されるリストを初期化
void InitializeAppliedList(HMODULE hModule) {
	g_Applied = NULL;

	TCHAR fn[MAX_PATH + 1];
	::GetModuleFileName(NULL, fn, MAX_PATH);
	PTCHAR fs = ::_tcsrchr(fn, _T('\\'));
	fs = (fs == NULL) ? fn : fs + 1;

	if (::LoadString(hModule, IDS_REG_CONFIG, g_RegPath, MAX_PATH) == 0) {
		::_tcscpy_s(g_RegPath, MAX_PATH, _T("HKCU\\Software\\HoPrRe"));
	}
	TCHAR szVNPat[80];
	if (::LoadString(hModule, IDS_REG_CONFIG_VFMT, szVNPat, 80) == 0) {
		::_tcscpy_s(szVNPat, 80, _T("RC_*"));
	}

	LPTSTR lpszRegSubKey = ::_tcschr(g_RegPath, _T('\\'));
	if (lpszRegSubKey != NULL) {
		*lpszRegSubKey = _T('\0');
		lpszRegSubKey++;
		if (::_tcsicmp(g_RegPath, _T("HKEY_LOCAL_MACHINE")) == 0 || ::_tcsicmp(g_RegPath, _T("HKLM")) == 0) {
			g_RegRoot = HKEY_LOCAL_MACHINE;
		} else if (::_tcsicmp(g_RegPath, _T("HKEY_CURRENT_USER")) == 0 || ::_tcsicmp(g_RegPath, _T("HKCU")) == 0) {
			g_RegRoot = HKEY_CURRENT_USER;
		}
	} else {
		lpszRegSubKey = g_RegPath;
	}
	
	HKEY hKey = NULL;
	if (::RegOpenKeyEx(g_RegRoot, lpszRegSubKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
		return;
	}
	
	#define VNAMELEN 80
	TCHAR vname[VNAMELEN];
	DWORD vnlen;
	DWORD vtype;
	for (DWORD dwIndex = 0; ; dwIndex++) {
		vnlen = VNAMELEN;
		if (::RegEnumValue(hKey, dwIndex, vname, &vnlen, NULL, &vtype, NULL, NULL) != ERROR_SUCCESS) {
			break;
		}
		if (::PathMatchSpec(vname, szVNPat) && vtype == REG_BINARY) {
			BYTE dummy;
			DWORD vdlen = sizeof(dummy);
			::RegQueryValueEx(hKey, vname, NULL, &vtype, &dummy, &vdlen);
			LPBYTE vdata = new BYTE[vdlen];
			::RegQueryValueEx(hKey, vname, NULL, &vtype, vdata, &vdlen);
			LPCDEFREG pDef = (LPCDEFREG)vdata;
			if (pDef->dwType == CDEFREG_TYPE_RC01) {
				if (pDef->szModule[0] == _T('\0') || ::PathMatchSpec(fs, pDef->szModule)) {
					HOPRRE_ENTRY *newone = new HOPRRE_ENTRY;
					newone->pNext = g_Applied;
					newone->c = pDef->c;
					g_Applied = newone;
				}
			}
			delete [] vdata;
		}
	}

	if (IsLogEnabled()) {
		FILE *f;
		::_tfopen_s(&f, g_LogFile.path, _T("a"));
		if (f != NULL) {
			int count = 0;
			HOPRRE_ENTRY *cur = g_Applied;
			while (cur != NULL) {
				count++;
				cur = cur->pNext;
			}
			if (count > 0) {
				::_ftprintf(f, _T("%s: %d rules applied.\r\n"), fs, count);
			}
			::fclose(f);
		}
	}
}