Exemple #1
0
BOOL RegisterStateChangeCallback (
    UINT32 CodeOffset,
    UINT32 RegisterNumber,
    GcSlotFlags Flags,
    GcSlotState NewState,
    PVOID pvData)
{
    GcInfoDumpState *pState = (GcInfoDumpState*)pvData;

    if (pState->fSafePoint && (GC_SLOT_LIVE != NewState))
    {
        // Don't print deaths for safepoints
        return FALSE;
    }

    if (pState->LastCodeOffset != CodeOffset)
    {
        if (pState->fAnythingPrinted)
            pState->pfnPrintf("\n");

        pState->pfnPrintf("%08x", CodeOffset);

        pState->LastCodeOffset = CodeOffset;
    }

    char delta = ((GC_SLOT_LIVE == NewState) ? '+' : '-');

    pState->pfnPrintf(" %c%s", delta, GetRegName(RegisterNumber));

    PrintFlags(pState->pfnPrintf, Flags);

    pState->fAnythingPrinted = TRUE;

    return FALSE;
}
Exemple #2
0
BOOL Cfg::LoadPacket(int idx, MsgBuf *msg, char *head, ULONG *img_base)
{
	char	key[MAX_LISTBUF];
	GetRegName(key, nicAddr, portNo);
	TRegistry	reg(HS_TOOLS, key);

	if (!reg.CreateKey(SAVEPACKETKEY_STR)) return FALSE;
	if (!reg.EnumKey(idx, key, sizeof(key))) return FALSE;
	if (!reg.OpenKey(key)) return FALSE;

	int	size = (int)offsetof(MsgBuf, msgBuf);
	reg.GetByte(MSGHEADKEY_STR, (BYTE *)msg, &size);

	size = (int)sizeof(msg->msgBuf);
	reg.GetByte(MSGBUFKEY_STR, (BYTE *)msg->msgBuf, &size);
	size = (int)sizeof(msg->exBuf);
	reg.GetByte(MSGEXBUFKEY_STR, (BYTE *)msg->exBuf, &size);
	size = (int)sizeof(msg->packetNoStr);
	reg.GetByte(MSGPKTNOKEY_STR, (BYTE *)msg->packetNoStr, &size);
	size = MAX_LISTBUF;
	reg.GetByte(HEADKEY_STR, (BYTE *)head, &size);
	reg.GetInt(IMGBASEKEY_STR, (int *)img_base);

	return TRUE;
}
Exemple #3
0
BOOL Cfg::CleanupPackets()
{
	char	key[MAX_LISTBUF];
	GetRegName(key, nicAddr, portNo);
	TRegistry	reg(HS_TOOLS, key);

	return	reg.DeleteChildTree(SAVEPACKETKEY_STR);
}
Exemple #4
0
BOOL Cfg::DeletePacket(ULONG packetNo, const char *userName)
{
	char	key[MAX_LISTBUF];
	GetRegName(key, nicAddr, portNo);
	TRegistry	reg(HS_TOOLS, key);

	if (!reg.CreateKey(SAVEPACKETKEY_STR)) return FALSE;

	sprintf(key, "%x:%s", packetNo, userName);
	return	reg.DeleteKey(key);
}
Exemple #5
0
BOOL Cfg::SavePacket(const MsgBuf *msg, const char *head, ULONG img_base)
{
	char	key[MAX_LISTBUF];
	GetRegName(key, nicAddr, portNo);
	TRegistry	reg(HS_TOOLS, key);

	if (!reg.CreateKey(SAVEPACKETKEY_STR)) return FALSE;

	sprintf(key, "%x:%s", msg->packetNo, msg->hostSub.userName);
	if (!reg.CreateKey(key)) return FALSE;

	reg.SetByte(MSGHEADKEY_STR, (BYTE *)msg, (int)offsetof(MsgBuf, msgBuf));
	reg.SetByte(MSGBUFKEY_STR, (BYTE *)msg->msgBuf, (int)strlen(msg->msgBuf)+1);
	reg.SetByte(MSGEXBUFKEY_STR, (BYTE *)msg->exBuf, (int)strlen(msg->exBuf)+1);
	reg.SetByte(MSGPKTNOKEY_STR, (BYTE *)msg->packetNoStr, (int)strlen(msg->packetNoStr)+1);
	reg.SetByte(HEADKEY_STR, (BYTE *)head, (int)strlen(head)+1);
	reg.SetInt(IMGBASEKEY_STR, (int)img_base);

	return TRUE;
}
Exemple #6
0
size_t      GCDump::DumpGCTable(PTR_CBYTE      gcInfoBlock,
                                unsigned       methodSize,
                                bool           verifyGCTables)
{
    GCInfoToken gcInfoToken = { dac_cast<PTR_VOID>(gcInfoBlock), gcInfoVersion };
    GcInfoDecoder hdrdecoder(gcInfoToken,
                             (GcInfoDecoderFlags)(  DECODE_SECURITY_OBJECT
                                     | DECODE_GS_COOKIE
                                     | DECODE_CODE_LENGTH
                                     | DECODE_PSP_SYM
                                     | DECODE_VARARG
                                     | DECODE_GENERICS_INST_CONTEXT
                                     | DECODE_GC_LIFETIMES
                                     | DECODE_PROLOG_LENGTH
                                     | DECODE_RETURN_KIND),
                             0);

    if (NO_SECURITY_OBJECT != hdrdecoder.GetSecurityObjectStackSlot() ||
            NO_GENERICS_INST_CONTEXT != hdrdecoder.GetGenericsInstContextStackSlot() ||
            NO_GS_COOKIE == hdrdecoder.GetGSCookieStackSlot())
    {
        gcPrintf("Prolog size: ");
        UINT32 prologSize = hdrdecoder.GetPrologSize();
        gcPrintf("%d\n", prologSize);
    }

    gcPrintf("Security object: ");
    if (NO_SECURITY_OBJECT == hdrdecoder.GetSecurityObjectStackSlot())
    {
        gcPrintf("<none>\n");
    }
    else
    {
        INT32 ofs = hdrdecoder.GetSecurityObjectStackSlot();
        char sign = '+';

        if (ofs < 0)
        {
            sign = '-';
            ofs = -ofs;
        }

        gcPrintf("caller.sp%c%x\n", sign, ofs);
    }

    gcPrintf("GS cookie: ");
    if (NO_GS_COOKIE == hdrdecoder.GetGSCookieStackSlot())
    {
        gcPrintf("<none>\n");
    }
    else
    {
        INT32 ofs = hdrdecoder.GetGSCookieStackSlot();
        char sign = '+';

        if (ofs < 0)
        {
            sign = '-';
            ofs = -ofs;
        }

        gcPrintf("caller.sp%c%x\n", sign, ofs);

        UINT32 validRangeStart = hdrdecoder.GetGSCookieValidRangeStart();
        UINT32 validRangeEnd = hdrdecoder.GetGSCookieValidRangeEnd();
        gcPrintf("GS cookie valid range: [%x;%x)\n", validRangeStart, validRangeEnd);
    }

    gcPrintf("PSPSym: ");
    if (NO_PSP_SYM == hdrdecoder.GetPSPSymStackSlot())
    {
        gcPrintf("<none>\n");
    }
    else
    {
        INT32 ofs = hdrdecoder.GetPSPSymStackSlot();
        char sign = '+';

        if (ofs < 0)
        {
            sign = '-';
            ofs = -ofs;
        }

#ifdef _TARGET_AMD64_
        // The PSPSym is relative to InitialSP on X64 and CallerSP on other platforms.
        gcPrintf("initial.sp%c%x\n", sign, ofs);
#else
        gcPrintf("caller.sp%c%x\n", sign, ofs);
#endif
    }

    gcPrintf("Generics inst context: ");
    if (NO_GENERICS_INST_CONTEXT == hdrdecoder.GetGenericsInstContextStackSlot())
    {
        gcPrintf("<none>\n");
    }
    else
    {
        INT32 ofs = hdrdecoder.GetGenericsInstContextStackSlot();
        char sign = '+';

        if (ofs < 0)
        {
            sign = '-';
            ofs = -ofs;
        }

        gcPrintf("caller.sp%c%x\n", sign, ofs);
    }

    gcPrintf("PSP slot: ");
    if (NO_PSP_SYM == hdrdecoder.GetPSPSymStackSlot())
    {
        gcPrintf("<none>\n");
    }
    else
    {
        INT32 ofs = hdrdecoder.GetPSPSymStackSlot();
        char sign = '+';

        if (ofs < 0)
        {
            sign = '-';
            ofs = -ofs;
        }

        gcPrintf("caller.sp%c%x\n", sign, ofs);

    }

    gcPrintf("GenericInst slot: ");
    if (NO_GENERICS_INST_CONTEXT == hdrdecoder.GetGenericsInstContextStackSlot())
    {
        gcPrintf("<none>\n");
    }
    else
    {
        INT32 ofs = hdrdecoder.GetGenericsInstContextStackSlot();
        char sign = '+';

        if (ofs < 0)
        {
            sign = '-';
            ofs = -ofs;
        }

        gcPrintf("caller.sp%c%x ", sign, ofs);

        if (hdrdecoder.HasMethodDescGenericsInstContext())
            gcPrintf("(GENERIC_PARAM_CONTEXT_METHODDESC)\n");
        else if (hdrdecoder.HasMethodTableGenericsInstContext())
            gcPrintf("(GENERIC_PARAM_CONTEXT_METHODHANDLE)\n");
        else
            gcPrintf("(GENERIC_PARAM_CONTEXT_THIS)\n");
    }

    gcPrintf("Varargs: %u\n", hdrdecoder.GetIsVarArg());
    gcPrintf("Frame pointer: %s\n", NO_STACK_BASE_REGISTER == hdrdecoder.GetStackBaseRegister()
             ? "<none>"
             : GetRegName(hdrdecoder.GetStackBaseRegister()));

    gcPrintf("Wants Report Only Leaf: %u\n", hdrdecoder.WantsReportOnlyLeaf());

#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA
    gcPrintf("Size of parameter area: %x\n", hdrdecoder.GetSizeOfStackParameterArea());
#endif

    ReturnKind returnKind = hdrdecoder.GetReturnKind();
    gcPrintf("Return Kind: %s\n", ReturnKindToString(returnKind));

    UINT32 cbEncodedMethodSize = hdrdecoder.GetCodeLength();
    gcPrintf("Code size: %x\n", cbEncodedMethodSize);

    GcInfoDumper dumper(gcInfoToken);

    GcInfoDumpState state;
    state.LastCodeOffset = -1;
    state.fAnythingPrinted = FALSE;
    state.fSafePoint = FALSE;
    state.FrameRegister = hdrdecoder.GetStackBaseRegister();
    state.pfnPrintf = gcPrintf;

    GcInfoDumper::EnumerateStateChangesResults result = dumper.EnumerateStateChanges(
                &InterruptibleStateChangeCallback,
                &RegisterStateChangeCallback,
                &StackSlotStateChangeCallback,
                &SafePointCallback,
                &state);

    if (state.fAnythingPrinted)
        gcPrintf("\n");

    switch (result)
    {
    case GcInfoDumper::SUCCESS:
        // do nothing
        break;

    case GcInfoDumper::OUT_OF_MEMORY:
        gcPrintf("out of memory\n");
        break;

    case GcInfoDumper::REPORTED_REGISTER_IN_CALLERS_FRAME:
        gcPrintf("reported register in caller's frame\n");
        break;

    case GcInfoDumper::REPORTED_FRAME_POINTER:
        gcPrintf("reported frame register\n");
        break;

    case GcInfoDumper::REPORTED_INVALID_BASE_REGISTER:
        gcPrintf("reported pointer relative to wrong base register\n");
        break;

    case GcInfoDumper::REPORTED_INVALID_POINTER:
        gcPrintf("reported invalid pointer\n");
        break;

    case GcInfoDumper::DECODER_FAILED:
        gcPrintf("decoder failed\n");
        break;

    default:
        gcPrintf("invalid GC info\n");
        break;
    }

    return (result == GcInfoDumper::SUCCESS) ? dumper.GetGCInfoSize() : 0;
}
Exemple #7
0
BOOL StackSlotStateChangeCallback (
    UINT32 CodeOffset,
    GcSlotFlags flags,
    GcStackSlotBase BaseRegister,
    SSIZE_T StackOffset,
    GcSlotState NewState,
    PVOID pvData)
{
    GcInfoDumpState *pState = (GcInfoDumpState*)pvData;

    if (pState->fSafePoint && (GC_SLOT_LIVE != NewState))
    {
        // Don't print deaths for safepoints
        return FALSE;
    }

    if (pState->LastCodeOffset != CodeOffset)
    {
        if (pState->fAnythingPrinted)
            pState->pfnPrintf("\n");

        if ((CodeOffset == -2) && !pState->fAnythingPrinted)
            pState->pfnPrintf("Untracked:");
        else
            pState->pfnPrintf("%08x", CodeOffset);

        pState->LastCodeOffset = CodeOffset;
    }

    char delta = ((GC_SLOT_LIVE == NewState) ? '+' : '-');

    CHAR sign = '+';

    // the dumper's call back (in GcInfoDumper.cpp) has to "guess" the base register
    // for stack slots it usually guesses it wrong ......
    // We try to filter out at least the non-sensical combinations
    //     - negative offset relative to SP
    //     - positive offset relative to CALLER_SP

    if (StackOffset < 0)
    {
        StackOffset = -StackOffset;
        sign = '-';
#ifndef GCINFODUMPER_IS_FIXED
        if (BaseRegister == GC_SP_REL)
        {   // negative offset to SP????
            BaseRegister = GC_CALLER_SP_REL;
        }
#endif // !GCINFODUMPER_IS_FIXED
    }
#ifndef GCINFODUMPER_IS_FIXED
    else if (BaseRegister == GC_CALLER_SP_REL)
    {   // positive offset to Caller_SP????
        BaseRegister = GC_SP_REL;
    }
#endif // !GCINFODUMPER_IS_FIXED



    PCSTR pszBaseReg;

    switch (BaseRegister)
    {
    case GC_CALLER_SP_REL:
        pszBaseReg = "caller.sp";
        break;
    case GC_SP_REL:
        pszBaseReg = "sp";
        break;
    case GC_FRAMEREG_REL:
        pszBaseReg = GetRegName(pState->FrameRegister);
        break;
    default:
        pszBaseReg = "???";
        break;
    }

    pState->pfnPrintf(" %c%s%c%x", delta, pszBaseReg, sign, StackOffset);

    PrintFlags(pState->pfnPrintf, flags);

    pState->fAnythingPrinted = TRUE;

    return FALSE;
}
Exemple #8
0
BOOL Cfg::WriteRegistry(int ctl_flg)
{
	char	buf[MAX_LISTBUF], val[MAX_LISTBUF];
	int		i;

	GetRegName(buf, nicAddr, portNo);
	TRegistry	reg(HS_TOOLS, buf);

	if (ctl_flg & CFG_GENERAL)
	{
		reg.SetStr(NULL, GetVersionStr());
		reg.SetInt(LCID_KEY, lcid);
		reg.SetInt(NOBEEP_STR, NoBeep);
		reg.SetInt(NOTCP_STR, NoTcp);
		reg.SetInt(LISTGET_STR, ListGet);
		reg.SetInt(LISTGETMSEC_STR, (int)ListGetMSec);
		reg.SetInt(RETRYMSEC_STR, (int)RetryMSec);
		reg.SetInt(RETRYMAX_STR, (int)RetryMax);
		reg.SetInt(IsWinNT() ? RECVMAXNT_STR : RECVMAX95_STR, (int)RecvMax);
		reg.SetInt(NOERASE_STR, NoErase);
//		reg.SetInt(DEBUG_STR, Debug);
		reg.SetInt(NOPOPUPCHECK_STR, NoPopupCheck);
		reg.SetInt(OPENCHECK_STR, OpenCheck);
		reg.SetInt(ALLOWSENDLIST_STR, AllowSendList);
		reg.SetInt(FILETRANSOPT_STR, fileTransOpt);
		reg.SetInt(RESOLVEOPT_STR, ResolveOpt);
//		reg.SetInt(LETTERKEY_STR, LetterKey);

//		reg.SetInt(REMOTEGRACE_STR, RemoteGraceSec);
		reg.SetStr(REBOOT_STR, RemoteReboot);
		reg.SetInt(REBOOTMODE_STR, RemoteRebootMode);
		reg.SetStr(EXIT_STR, RemoteExit);
		reg.SetInt(EXITMODE_STR, RemoteExitMode);

		reg.SetInt(CLIPMODE_STR, ClipMode);
//		reg.SetInt(CLIPMAX_STR, ClipMax);
//		reg.SetInt(CAPTUREDELAY_STR, CaptureDelay);
//		reg.SetInt(CAPTUREDELAYEX_STR, CaptureDelayEx);
		reg.SetInt(CAPTUREMINIMIZE_STR, CaptureMinimize);
		reg.SetInt(CAPTURECLIP_STR, CaptureClip);
		reg.SetInt(CAPTURESAVE_STR, CaptureSave);
		reg.SetInt(OPENMSGTIME_STR, OpenMsgTime);
		reg.SetInt(RECVMSGTIME_STR, RecvMsgTime);
		reg.SetInt(BALLOONNOINFO_STR, BalloonNoInfo);
//		reg.SetInt(TASKBARUI_STR, TaskbarUI);
//		reg.SetInt(MARKERTHICK_STR, MarkerThick);

		if (IsWinVista()) reg.SetInt(IPV6MODE_STR, IPv6ModeNext);
//		if (IsWinVista()) reg.SetStr(IPV6MULITCAST, IPv6Multicast);

//		reg.SetInt(VIEWMAX_STR, ViewMax);
//		reg.SetInt(TRANSMAX_STR, TransMax);
//		reg.SetInt(TCPBUFMAX_STR, TcpbufMax);
//		reg.SetInt(IOBUFMAX_STR, IoBufMax);
		reg.SetInt(LUMPCHECK_STR, LumpCheck);
		reg.SetInt(ENCTRANSCHECK_STR, EncTransCheck);
	}

	if (ctl_flg & CFG_ABSENCE)
	{
		reg.SetInt(ABSENCESAVE_STR, AbsenceSave);
		reg.SetInt(ABSENCECHECK_STR, AbsenceCheck);
		reg.SetInt(ABSENCEMAX_STR, AbsenceMax);
		if (reg.CreateKey(ABSENCESTR_STR))
		{
			for (i=0; i < AbsenceMax; i++)
			{
				char	key[MAX_PATH_U8];
				sprintf(key, "%s%d", ABSENCESTR_STR, i);
				reg.SetStr(key, AbsenceStr[i]);
				sprintf(key, "%s%d", ABSENCEHEAD_STR, i);
				reg.SetStr(key, AbsenceHead[i]);
			}
		}
		reg.CloseKey();
	}

	if (ctl_flg & CFG_GENERAL)
	{
		reg.SetStr(PASSWORD_STR, PasswordStr);
		reg.SetInt(PASSWDLOGCHECK_STR, PasswdLogCheck);
		reg.SetInt(DELAYTIME_STR, DelayTime);
		reg.SetInt(QUOTECHECK_STR, QuoteCheck);
		reg.SetInt(SECRETCHECK_STR, SecretCheck);
		reg.SetInt(LOGONLOG_STR, LogonLog);
		reg.SetInt(RECVLOGONDISP_STR, RecvLogonDisp);
		reg.SetInt(IPADDRCHECK_STR, IPAddrCheck);
		reg.SetInt(RECVIPADDRCHECK_STR, RecvIPAddr);
		reg.SetInt(ONECLICKPOPUP_STR, OneClickPopup);
		reg.SetInt(BALLOONNOTIFY_STR, BalloonNotify);		
		reg.SetInt(TRAYICON_STR, TrayIcon);
		reg.SetInt(ABNORMALBTN_STR, AbnormalButton);
		reg.SetInt(DIALUPCHECK_STR, DialUpCheck);
		reg.SetInt(ABSENCENONPOPUP_STR, AbsenceNonPopup);
		reg.SetStr(NICKNAMESTR_STR, NickNameStr);
		reg.SetStr(GROUPNAMESTR_STR, GroupNameStr);
		reg.SetLong(SORT_STR, Sort);
		reg.SetInt(UPDATETIME_STR, UpdateTime);
		reg.SetInt(KEEPHOSTTIME_STR, KeepHostTime);
		reg.SetInt(EXTENDENTRY_STR, ExtendEntry);
		reg.SetInt(EXTENDBROADCAST_STR, ExtendBroadcast);
		reg.SetInt(MULTICASTMODE_STR, MulticastMode);
		reg.SetInt(CONTROLIME_STR, ControlIME);
		reg.SetInt(GRIDLINE_STR, GridLineCheck);
		reg.SetInt(COLUMNITEMS_STR, ColumnItems);
		reg.SetStr(QUOTESTR_STR, QuoteStr);
		if (reg.CreateKey(HOTKEY_STR))
		{
			reg.SetInt(HOTKEYCHECK_STR, HotKeyCheck);
			reg.SetInt(HOTKEYMODIFY_STR, HotKeyModify);
			reg.SetInt(HOTKEYSEND_STR, HotKeySend);
			reg.SetInt(HOTKEYRECV_STR, HotKeyRecv);
			reg.SetInt(HOTKEYMISC_STR, HotKeyMisc);
			reg.CloseKey();
		}
		reg.SetInt(LOGCHECK_STR, LogCheck);
		reg.SetInt(LOGUTF8_STR, LogUTF8);
		reg.SetStr(LOGFILE_STR, LogFile);
		reg.SetStr(SOUNDFILE_STR, SoundFile);
		reg.SetStr(ICON_STR, IconFile);
		reg.SetStr(REVICON_STR, RevIconFile);
		reg.SetStr(LASTOPEN_STR, lastOpenDir);
		reg.SetStr(LASTSAVE_STR, lastSaveDir);
		reg.SetInt(LRUUSERMAX_STR, lruUserMax);

		reg.SetStr(AUTOSAVEDIR_STR,   autoSaveDir);
		reg.SetInt(AUTOSAVETOUT_STR,  autoSaveTout);
		reg.SetInt(AUTOSAVEMAX_STR,   autoSaveMax);
		reg.SetInt(AUTOSAVELEVEL_STR, autoSaveLevel);
		reg.SetInt(AUTOSAVEFLAGS_STR, autoSaveFlags);
	}

	if ((ctl_flg & CFG_WINSIZE) && reg.CreateKey(WINSIZE_STR))
	{
		reg.SetInt(SENDNICKNAME_STR, SendWidth[SW_NICKNAME]);
		reg.SetInt(SENDUSERNAME_STR, SendWidth[SW_USER]);
		reg.SetInt(SENDABSENCE_STR, SendWidth[SW_ABSENCE]);
		reg.SetInt(SENDPRIORITY_STR, SendWidth[SW_PRIORITY]);
		reg.SetInt(SENDGROUPNAME_STR, SendWidth[SW_GROUP]);
		reg.SetInt(SENDHOSTNAME_STR, SendWidth[SW_HOST]);
		reg.SetInt(SENDIPADDR_STR, SendWidth[SW_IPADDR]);

		if (reg.CreateKey(SENDORDER_STR))
		{
			for (i=0; i < MAX_SENDWIDTH; i++)
			{
				sprintf(buf, "%d", i);
				reg.SetInt(buf, SendOrder[i]);
			}
			reg.CloseKey();
		}

		reg.SetInt(SENDXDIFF_STR, SendXdiff);
		reg.SetInt(SENDYDIFF_STR, SendYdiff);
		reg.SetInt(SENDMIDYDIFF_STR, SendMidYdiff);
		reg.SetInt(SENDSAVEPOS_STR, SendSavePos);
		reg.SetInt(SENDXPOS_STR, SendXpos);
		reg.SetInt(SENDYPOS_STR, SendYpos);

		reg.SetInt(RECVXDIFF_STR, RecvXdiff);
		reg.SetInt(RECVYDIFF_STR, RecvYdiff);
		reg.SetInt(RECVSAVEPOS_STR, RecvSavePos);
		reg.SetInt(RECVXPOS_STR, RecvXpos);
		reg.SetInt(RECVYPOS_STR, RecvYpos);

		reg.SetInt(HISTXDIFF_STR, HistXdiff);
		reg.SetInt(HISTYDIFF_STR, HistYdiff);
		reg.SetInt(HISTUSER_STR, HistWidth[HW_USER]);
		reg.SetInt(HISTODATE_STR, HistWidth[HW_ODATE]);
		reg.SetInt(HISTSDATE_STR, HistWidth[HW_SDATE]);
		reg.SetInt(HISTID_STR, HistWidth[HW_ID]);

		reg.CloseKey();
	}

	if ((ctl_flg & CFG_FONT) && reg.CreateKey(FONT_STR))
	{
		WriteFontRegistry(&reg, SENDEDITFONT_STR, &SendEditFont);
		WriteFontRegistry(&reg, SENDLISTFONT_STR, &SendListFont);
		WriteFontRegistry(&reg, RECVHEADFONT_STR, &RecvHeadFont);
		WriteFontRegistry(&reg, RECVEDITFONT_STR, &RecvEditFont);
		WriteFontRegistry(&reg, LOGVIEWFONT_STR, &LogViewFont);
		reg.CloseKey();
	}

	if ((ctl_flg & CFG_BROADCAST) && reg.CreateKey(BROADCAST_STR))
	{
		i = 0;
		for (TBrObj *obj=brList.TopObj(); obj; obj=brList.NextObj(obj))
		{
			sprintf(buf, "%d", i++);
			reg.SetStr(buf, obj->Host());
		}
		while (1)
		{
			sprintf(buf, "%d", i++);
			if (!reg.GetStr(buf, val, sizeof(val)))
				break;
			if (!reg.DeleteValue(buf))
				break;
		}
		reg.CloseKey();
	}

	if (ctl_flg & CFG_CLICKURL)
	{
		reg.SetInt(DEFAULTURL_STR, DefaultUrl);
		reg.SetInt(SHELLEXEC_STR, ShellExec);
		if (reg.CreateKey(CLICKABLEURL_STR))
		{

			for (UrlObj *obj = urlList.TopObj(); obj; obj = urlList.NextObj(obj))
				reg.SetStr(obj->protocol, obj->program);
			reg.CloseKey();
		}
	}

	if ((ctl_flg & CFG_PRIORITY) && reg.CreateKey(PRIORITY_STR))
	{
		reg.SetInt(PRIORITYMAX_STR, PriorityMax);
		reg.SetInt(PRIORITYREJECT_STR, PriorityReject);
#if 0
		for (i=0; i < PriorityMax; i++)
		{
			sprintf(buf, "%d", i);

			if (reg.CreateKey(buf))
			{
				reg.SetStr(PRIORITYSOUND_STR, PrioritySound[i] ? PrioritySound[i] : "");
				reg.CloseKey();
			}
		}
#endif
		reg.CloseKey();
	}

	if ((ctl_flg & CFG_HOSTINFO) && reg.CreateKey(HOSTINFO_STR))
	{
		Time_t	now_time = Time();
		BYTE	pubkey[MAX_BUF];
		int		pubkeySize;

		if (ctl_flg & CFG_DELHOST)
			reg.DeleteChildTree();

		for (i=0; i < priorityHosts.HostCnt(); i++)
		{
			Host	*host = priorityHosts.GetHost(i);
			int		to_store_size = 2048 / 8; // 2048bits RSA key
			sprintf(buf, "%s:%s", host->hostSub.userName, host->hostSub.hostName);

			if (host->updateTime + KeepHostTime < now_time ||
				(host->pubKey.KeyLen() < to_store_size && host->priority == DEFAULT_PRIORITY))
			{
				if (ctl_flg & CFG_DELCHLDHOST)
					reg.DeleteChildTree(buf);
			}
			else if (reg.CreateKey(buf))
			{
				reg.SetStr(USERNAME_STR, host->hostSub.userName);
				reg.SetStr(HOSTNAME_STR, host->hostSub.hostName);
				reg.SetLong(IPADDR_STR, host->hostSub.addr.V4Addr());
				reg.SetInt(PORTNO_STR, host->hostSub.portNo);
				reg.SetStr(NICKNAME_STR, host->nickName);
				reg.SetStr(GROUPNAME_STR, host->groupName);
				if (*host->alterName) reg.SetStr(ALTERNAME_STR, host->alterName);
				reg.SetInt(PRIORITY_STR, host->priority);
				reg.SetLong(UPDATETIME_STR, (long)host->updateTime);
				if (host->pubKey.KeyLen() >= to_store_size) {
					char	*p = (char *)GetUserNameDigestField(host->hostSub.userName);
					if (p && (pubkeySize = host->pubKey.Serialize(pubkey, sizeof(pubkey))) > 0) {
						reg.SetByte(PUBLICKEY_STR, pubkey, pubkeySize);
					}
				}
				reg.CloseKey();
			}
		}
		reg.CloseKey();
	}

	if ((ctl_flg & CFG_FINDHIST) && reg.CreateKey(FINDSTR_STR))
	{
		reg.SetInt(FINDMAX_STR, FindMax);
		reg.SetInt(FINDALL_STR, FindAll);
		for (i=0; i < FindMax; i++)
		{
			char	key[MAX_PATH_U8];
			sprintf(key, "%d", i);
			reg.SetStr(key, FindStr[i]);
		}
		reg.CloseKey();
	}

	if (ctl_flg & CFG_LRUUSER) {
		reg.DeleteChildTree(LRUUSERKEY_STR);
		if (reg.CreateKey(LRUUSERKEY_STR)) {
			UsersObj *obj=lruUserList.TopObj();
			for (i=0; obj; i++) {
				sprintf(buf, "%d", i);
				if (!reg.CreateKey(buf)) break;
				UserObj *u = obj->users.TopObj();
				for (int j=0; u; j++) {
					sprintf(buf, "%d", j);
					if (!reg.CreateKey(buf)) break;
					reg.SetStr(USERNAME_STR, u->hostSub.userName);
					reg.SetStr(HOSTNAME_STR, u->hostSub.hostName);
					reg.CloseKey();
					u = obj->users.NextObj(u);
				}
				reg.CloseKey();
				obj = lruUserList.NextObj(obj);
			}
			reg.CloseKey();
		}
	}

// private/public key
	if (ctl_flg & CFG_CRYPT) {
		for (int i=KEY_1024; i <= KEY_2048; i++) {
			const char *key = (i == KEY_1024) ? CRYPT_STR : CRYPT2_STR;
			if (reg.CreateKey(key) && priv[i].blob)
			{
				reg.SetByte(PRIVBLOB_STR, priv[i].blob, priv[i].blobLen);
				if (priv[i].encryptSeed)
					reg.SetByte(PRIVSEED_STR, priv[i].encryptSeed, priv[i].encryptSeedLen);
				reg.SetInt(PRIVTYPE_STR, priv[i].encryptType);
				reg.CloseKey();
			}
		}
	}

	return	TRUE;
}
Exemple #9
0
BOOL Cfg::ReadRegistry(void)
{
	char	buf[MAX_BUF], val[MAX_BUF];
	int		i;

	GetRegName(buf, nicAddr, portNo);
	TRegistry	reg(HS_TOOLS, buf);

	if (!reg.GetInt(NOPOPUPCHECK_STR, &NoPopupCheck))
	{
		GetRegName(buf, 0, portNo);
		reg.ChangeApp(HS_TOOLS, buf);
		if (!reg.GetInt(NOPOPUPCHECK_STR, &NoPopupCheck))
			reg.ChangeApp(HS_TOOLS, GetLoadStr(IDS_IPMSG));
	}

	lcid = -1;
	NoBeep = FALSE;
	NoTcp = FALSE;
	ListGet = FALSE;
	HotKeyCheck = TRUE;
	HotKeyModify = MOD_ALT|MOD_CONTROL;
	HotKeySend = 'S';
	HotKeyRecv = 'R';
	HotKeyMisc = 'D';
	ListGetMSec = IPMSG_DEFAULT_LISTGETMSEC;
	RetryMSec = IPMSG_DEFAULT_RETRYMSEC;
	RetryMax = IPMSG_DEFAULT_RETRYMAX;
	RecvMax = IsWinNT() ? IPMSG_DEFAULT_RECVMAX_NT : IPMSG_DEFAULT_RECVMAX_95;
	NoErase = FALSE;
	Debug = FALSE;
	NoPopupCheck = TRUE;
	OpenCheck = 1;
	AbsenceSave = FALSE;
	AbsenceCheck = FALSE;
	AbsenceMax = IPMSG_DEFAULT_ABSENCEMAX;
	AbsenceChoice = 0;
	FindMax = IPMSG_DEFAULT_FINDMAX;
	FindAll = TRUE;
	DelayTime = IPMSG_DEFAULT_DELAY;
	QuoteCheck = TRUE;
	SecretCheck = TRUE;
	LogonLog = TRUE;
	RecvLogonDisp = FALSE;
	IPAddrCheck = TRUE;
	RecvIPAddr = TRUE;
	OneClickPopup = FALSE;
	BalloonNotify = TRUE;
	TrayIcon = TRUE;
	AbnormalButton = FALSE;
	DialUpCheck = FALSE;
	*NickNameStr = 0;
	*GroupNameStr = 0;
	AbsenceNonPopup = TRUE;
	Sort = IPMSG_NAMESORT;
	UpdateTime = IPMSG_DEFAULT_UPDATETIME;
	KeepHostTime = IPMSG_DEFAULT_KEEPHOSTTIME;
	DefaultUrl = TRUE;
	ShellExec = FALSE;
	ExtendEntry = TRUE;
	ExtendBroadcast = 1;
	MulticastMode = 0;

	ControlIME = 1;
	GridLineCheck = TRUE;
	PriorityMax = DEFAULT_PRIORITYMAX;
	PriorityReject = 0;
	AllowSendList = TRUE;
	fileTransOpt = 0;
	ResolveOpt = 0;
	LetterKey = IsLang(LANG_JAPANESE) ? FALSE : TRUE;

	RemoteGraceSec = IPMSG_DEFAULT_REMOTEGRACE;
	RemoteRebootMode = 0;
	*RemoteReboot = 0;
	RemoteExitMode = 0;
	*RemoteExit = 0;

	ClipMode = IPMSG_DEFAULT_CLIPMODE;
	ClipMax = IPMSG_DEFAULT_CLIPMAX;
	CaptureDelay   = 300;
	CaptureDelayEx = 500;
	CaptureMinimize = TRUE;
	CaptureClip = TRUE;
	CaptureSave = FALSE;
	OpenMsgTime = IPMSG_DEFAULT_OPENMSGTIME;
	RecvMsgTime = IPMSG_DEFAULT_RECVMSGTIME;
	BalloonNoInfo = FALSE;
	TaskbarUI = /*IsWin7() ? TRUE :*/ FALSE;
	MarkerThick = IPMSG_DEFAULT_MARKER_THICK;
	IPv6Mode = IPv6ModeNext = 0;
	strcpy(IPv6Multicast, IPMSG_DEFAULT_MULTICAST_ADDR6); // in ipmsg.h

	ViewMax = IPMSG_DEFAULT_VIEWMAX;
	TransMax = IPMSG_DEFAULT_TRANSMAX;
	TcpbufMax = IPMSG_DEFAULT_TCPBUFMAX;
	IoBufMax = IPMSG_DEFAULT_IOBUFMAX;
	LumpCheck = FALSE;
	EncTransCheck = TRUE;
	lruUserMax = IPMSG_DEFAULT_LRUUSERMAX;

	// CryptProtectData is available only Win2K/XP
	for (i=0; i < MAX_KEY; i++) {
		priv[i].encryptType = IsWin2K() ? PRIV_BLOB_DPAPI : PRIV_BLOB_RAW;
	}

	strncpyz(QuoteStr, IPMSG_DEFAULT_QUOTE, sizeof(QuoteStr));

	SendWidth[SW_NICKNAME] = IPMSG_DEFAULT_NICKNAMEWIDTH;
	SendWidth[SW_ABSENCE] = IPMSG_DEFAULT_ABSENCEWIDTH;
	SendWidth[SW_GROUP] = IPMSG_DEFAULT_GROUPWIDTH;
	SendWidth[SW_HOST] = IPMSG_DEFAULT_HOSTWIDTH;
	SendWidth[SW_IPADDR] = IPMSG_DEFAULT_IPADDRWIDTH;
	SendWidth[SW_USER] = IPMSG_DEFAULT_USERWIDTH;
	SendWidth[SW_PRIORITY] = IPMSG_DEFAULT_PRIORITYWIDTH;

	ColumnItems = 0;
	SetItem(&ColumnItems, SW_NICKNAME, TRUE);
	SetItem(&ColumnItems, SW_GROUP, TRUE);
	SetItem(&ColumnItems, SW_HOST, TRUE);

	for (i=0; i < MAX_SENDWIDTH; i++)
		SendOrder[i] = i;

	SendXdiff		= 0;
	SendYdiff		= 0;
	SendMidYdiff	= 0;
	SendSavePos		= 0;
	SendXpos		= 0;
	SendYpos		= 0;

	RecvXdiff		= 0;
	RecvYdiff		= 0;
	RecvSavePos		= 0;
	RecvXpos		= 0;
	RecvYpos		= 0;

	HistWidth[HW_USER]  = IPMSG_DEFAULT_HWUSER_WIDTH;
	HistWidth[HW_ODATE] = IPMSG_DEFAULT_HWODATE_WIDTH;
	HistWidth[HW_SDATE] = IPMSG_DEFAULT_HWSDATE_WIDTH;
	HistWidth[HW_ID]    = IPMSG_DEFAULT_HWID_WIDTH;
	HistXdiff		= 0;
	HistYdiff		= 0;

	LogCheck = TRUE;
	LogUTF8 = TRUE;
	PasswdLogCheck = FALSE;
	*SoundFile = 0;
	*IconFile = 0;
	*RevIconFile = 0;
	*lastSaveDir = *lastOpenDir = 0;

	*autoSaveDir  = 0;
	autoSaveTout  = IPMSG_DEFAULT_AUTOSAVE_TOUT;
	autoSaveLevel = 0;
	autoSaveFlags = 0;
	autoSaveMax   = IPMSG_DEFAULT_AUTOSAVE_MAX;

	memset(&SendEditFont, 0, sizeof(SendEditFont));
	memset(&SendListFont, 0, sizeof(SendListFont));
	memset(&RecvHeadFont, 0, sizeof(RecvHeadFont));
	memset(&RecvEditFont, 0, sizeof(RecvEditFont));
	memset(&LogViewFont, 0, sizeof(LogViewFont));

	reg.GetInt(LCID_KEY, &lcid);
	reg.GetInt(NOBEEP_STR, &NoBeep);
	reg.GetInt(NOTCP_STR, &NoTcp);
	reg.GetInt(LISTGET_STR, &ListGet);
	reg.GetInt(LISTGETMSEC_STR, (int *)&ListGetMSec);
	reg.GetInt(RETRYMSEC_STR, (int *)&RetryMSec);
	reg.GetInt(RETRYMAX_STR, (int *)&RetryMax);
	reg.GetInt(IsWinNT() ? RECVMAXNT_STR : RECVMAX95_STR, (int *)&RecvMax);
	reg.GetInt(NOERASE_STR, &NoErase);
	reg.GetInt(DEBUG_STR, &Debug);
	reg.GetInt(NOPOPUPCHECK_STR, &NoPopupCheck);
	reg.GetInt(OPENCHECK_STR, &OpenCheck);
	reg.GetInt(ABSENCESAVE_STR, &AbsenceSave);
	if (AbsenceSave)
		reg.GetInt(ABSENCECHECK_STR, &AbsenceCheck);
	reg.GetInt(ABSENCEMAX_STR, &AbsenceMax);
	reg.GetInt(ALLOWSENDLIST_STR, &AllowSendList);
	reg.GetInt(FILETRANSOPT_STR, &fileTransOpt);
	reg.GetInt(RESOLVEOPT_STR, &ResolveOpt);
	reg.GetInt(LETTERKEY_STR, &LetterKey);

	reg.GetInt(REMOTEGRACE_STR, &RemoteGraceSec);
	reg.GetStr(REBOOT_STR, RemoteReboot, sizeof(RemoteReboot));
	reg.GetInt(REBOOTMODE_STR, &RemoteRebootMode);
	reg.GetStr(EXIT_STR, RemoteExit, sizeof(RemoteExit));
	reg.GetInt(EXITMODE_STR, &RemoteExitMode);

	reg.GetInt(CLIPMODE_STR, &ClipMode);
	ClipMode |= CLIP_ENABLE;
	reg.GetInt(CLIPMAX_STR, &ClipMax);
	reg.GetInt(CAPTUREDELAY_STR, &CaptureDelay);
	reg.GetInt(CAPTUREDELAYEX_STR, &CaptureDelayEx);
	reg.GetInt(CAPTUREMINIMIZE_STR, &CaptureMinimize);
	reg.GetInt(CAPTURECLIP_STR, &CaptureClip);
	reg.GetInt(CAPTURESAVE_STR, &CaptureSave);
	reg.GetInt(OPENMSGTIME_STR, &OpenMsgTime);
	reg.GetInt(RECVMSGTIME_STR, &RecvMsgTime);
	reg.GetInt(BALLOONNOINFO_STR, &BalloonNoInfo);
	reg.GetInt(TASKBARUI_STR, &TaskbarUI);
	reg.GetInt(MARKERTHICK_STR, &MarkerThick);

	reg.GetStr(IPV6MULITCAST, IPv6Multicast, sizeof(IPv6Multicast));
	if (IsWinVista()) {
		reg.GetInt(IPV6MODE_STR, &IPv6Mode);
		if (nicAddr.size == 16 && !IPv6Mode) IPv6Mode = 2;
		reg.GetStr(IPV6MULITCAST, IPv6Multicast, sizeof(IPv6Multicast));
		if (!*IPv6Multicast) {
			strcpy(IPv6Multicast, IPMSG_DEFAULT_MULTICAST_ADDR6); // in ipmsg.h
		}
	}
	IPv6ModeNext = IPv6Mode;

// for File Transfer
	reg.GetInt(VIEWMAX_STR, &ViewMax);
	if (ViewMax < 1024 * 1024)	// 1MB 以下の MapFileOfView は認めない
		ViewMax = IPMSG_DEFAULT_VIEWMAX;
	reg.GetInt(TRANSMAX_STR, &TransMax);
	if (TransMax < 8 * 1024)	// 8KB 以下の file transfer buf は認めない
		TransMax = IPMSG_DEFAULT_TRANSMAX;
	reg.GetInt(TCPBUFMAX_STR, &TcpbufMax);
	if (TcpbufMax < 8 * 1024)	// 8KB 以下の sockbuf は認めない
		TcpbufMax = IPMSG_DEFAULT_TCPBUFMAX;
	reg.GetInt(IOBUFMAX_STR, &IoBufMax);
	if (IoBufMax < TransMax)	// transmax 以下の IO/Buf は認めない
		IoBufMax = TransMax;

	reg.GetInt(LUMPCHECK_STR, &LumpCheck);
	reg.GetInt(ENCTRANSCHECK_STR, &EncTransCheck);

// for Absence Message
	typedef char MaxBuf[MAX_PATH_U8];
	AbsenceStr = new MaxBuf[AbsenceMax];
	memset(AbsenceStr, 0, MAX_PATH_U8 * AbsenceMax);
	reg.GetStr(ABSENCESTR_STR, AbsenceStr[0], sizeof(AbsenceStr[0]));

	typedef char MaxHead[MAX_NAMEBUF];
	AbsenceHead = new MaxHead[AbsenceMax];
	memset(AbsenceHead, 0, MAX_NAMEBUF * AbsenceMax);

	if (reg.CreateKey(ABSENCESTR_STR))
	{
		for (i=0; i < AbsenceMax; i++)
		{
			char	key[MAX_PATH_U8];

			sprintf(key, "%s%d", ABSENCESTR_STR, i);
			if (!reg.GetStr(key, AbsenceStr[i], sizeof(AbsenceStr[i])))
				strncpyz(AbsenceStr[i], DefaultAbsence[i < IPMSG_DEFAULT_ABSENCEMAX ? i : 0], MAX_PATH_U8);

			sprintf(key, "%s%d", ABSENCEHEAD_STR, i);
			if (!reg.GetStr(key, AbsenceHead[i], sizeof(AbsenceHead[i])))
				strcpy(AbsenceHead[i], DefaultAbsenceHead[i < IPMSG_DEFAULT_ABSENCEMAX ? i : 0]);
		}
		reg.CloseKey();
	}

// Find User
	typedef char MaxFind[MAX_NAMEBUF];
	if (reg.CreateKey(FINDSTR_STR))
	{
		reg.GetInt(FINDMAX_STR, &FindMax);
		reg.GetInt(FINDALL_STR, &FindAll);
		FindStr = new MaxFind[FindMax];
		for (i=0; i < FindMax; i++)
		{
			char	key[MAX_PATH_U8];
			sprintf(key, "%d", i);
			if (!reg.GetStr(key, FindStr[i], sizeof(FindStr[i])))
				FindStr[i][0] = '\0';
		}
		reg.CloseKey();
	}
	else {
		FindStr = new MaxFind[FindMax];
		memset(FindStr, 0, MAX_NAMEBUF * FindMax);
	}

	reg.GetInt(LRUUSERMAX_STR, &lruUserMax);
	if (reg.OpenKey(LRUUSERKEY_STR)) {
		for (i=0; ; i++) {
			sprintf(buf, "%d", i);
			if (!reg.OpenKey(buf)) break;
			UsersObj *obj = new UsersObj;
			for (int j=0; ; j++) {
				sprintf(buf, "%d", j);
				if (!reg.OpenKey(buf)) break;
				UserObj *u = new UserObj;
				if (reg.GetStr(USERNAME_STR, u->hostSub.userName, sizeof(u->hostSub.userName)) &&
					reg.GetStr(HOSTNAME_STR, u->hostSub.hostName, sizeof(u->hostSub.userName))) {
					obj->users.AddObj(u);
				}
				reg.CloseKey();
			}
			reg.CloseKey();
			lruUserList.AddObj(obj);
		}
		reg.CloseKey();
	}

	*PasswordStr = 0;
	reg.GetStr(PASSWORD_STR, PasswordStr, sizeof(PasswordStr));
	reg.GetInt(PASSWDLOGCHECK_STR, &PasswdLogCheck);
	reg.GetInt(DELAYTIME_STR, &DelayTime);
	reg.GetInt(QUOTECHECK_STR, &QuoteCheck);
	reg.GetInt(SECRETCHECK_STR, &SecretCheck);
	reg.GetInt(LOGONLOG_STR, &LogonLog);
	reg.GetInt(RECVLOGONDISP_STR, &RecvLogonDisp);
	reg.GetInt(IPADDRCHECK_STR, &IPAddrCheck);
	reg.GetInt(RECVIPADDRCHECK_STR, &RecvIPAddr);
	reg.GetInt(ONECLICKPOPUP_STR, &OneClickPopup);
	reg.GetInt(BALLOONNOTIFY_STR, &BalloonNotify);
	reg.GetInt(TRAYICON_STR, &TrayIcon);
	reg.GetInt(ABNORMALBTN_STR, &AbnormalButton);
	reg.GetInt(DIALUPCHECK_STR, &DialUpCheck);
	reg.GetInt(ABSENCENONPOPUP_STR, &AbsenceNonPopup);
	reg.GetStr(NICKNAMESTR_STR, NickNameStr, sizeof(NickNameStr));
	StrictUTF8(NickNameStr);
	reg.GetStr(GROUPNAMESTR_STR, GroupNameStr, sizeof(GroupNameStr));
	StrictUTF8(GroupNameStr);
	reg.GetLong(SORT_STR, (long *)&Sort);
//	reg.GetInt(UPDATETIME_STR, &UpdateTime);
	reg.GetInt(KEEPHOSTTIME_STR, &KeepHostTime);
	reg.GetInt(DEFAULTURL_STR, &DefaultUrl);
	reg.GetInt(SHELLEXEC_STR, &ShellExec);
	reg.GetInt(EXTENDENTRY_STR, &ExtendEntry);
	reg.GetInt(EXTENDBROADCAST_STR, &ExtendBroadcast);

	reg.GetInt(MULTICASTMODE_STR, &MulticastMode);

	reg.GetInt(CONTROLIME_STR, &ControlIME);
	reg.GetInt(GRIDLINE_STR, &GridLineCheck);
	reg.GetInt(COLUMNITEMS_STR, (int *)&ColumnItems);
	reg.GetStr(QUOTESTR_STR, QuoteStr, sizeof(QuoteStr));
	if (reg.CreateKey(HOTKEY_STR))
	{
		reg.GetInt(HOTKEYCHECK_STR, &HotKeyCheck);
		reg.GetInt(HOTKEYMODIFY_STR, &HotKeyModify);
		reg.GetInt(HOTKEYSEND_STR, &HotKeySend);
		reg.GetInt(HOTKEYRECV_STR, &HotKeyRecv);
		reg.GetInt(HOTKEYMISC_STR, &HotKeyMisc);
		reg.CloseKey();
	}
	reg.GetInt(LOGCHECK_STR, &LogCheck);
	reg.GetInt(LOGUTF8_STR, &LogUTF8);
	if (!reg.GetStr(LOGFILE_STR, LogFile, sizeof(LogFile)) || !*LogFile)
		strncpyz(LogFile, "ipmsg.log", sizeof(LogFile));
	LogMng::StrictLogFile(LogFile);

	reg.GetStr(SOUNDFILE_STR, SoundFile, sizeof(SoundFile));
	reg.GetStr(ICON_STR, IconFile, sizeof(IconFile));
	reg.GetStr(REVICON_STR, RevIconFile, sizeof(RevIconFile));
	reg.GetStr(LASTOPEN_STR, lastOpenDir, sizeof(lastOpenDir));
	reg.GetStr(LASTSAVE_STR, lastSaveDir, sizeof(lastSaveDir));

	reg.GetStr(AUTOSAVEDIR_STR,   autoSaveDir, sizeof(autoSaveDir));
	reg.GetInt(AUTOSAVETOUT_STR,  &autoSaveTout);
	reg.GetInt(AUTOSAVEMAX_STR,   &autoSaveMax);
	reg.GetInt(AUTOSAVEFLAGS_STR, &autoSaveFlags);
	reg.GetInt(AUTOSAVELEVEL_STR, &autoSaveLevel);

// Send/Recv Window Location
	if (reg.CreateKey(WINSIZE_STR))
	{
		reg.GetInt(SENDNICKNAME_STR, &SendWidth[SW_NICKNAME]);
		reg.GetInt(SENDUSERNAME_STR, &SendWidth[SW_USER]);
		reg.GetInt(SENDABSENCE_STR, &SendWidth[SW_ABSENCE]);
		reg.GetInt(SENDPRIORITY_STR, &SendWidth[SW_PRIORITY]);
		reg.GetInt(SENDGROUPNAME_STR, &SendWidth[SW_GROUP]);
		reg.GetInt(SENDHOSTNAME_STR, &SendWidth[SW_HOST]);
		reg.GetInt(SENDIPADDR_STR, &SendWidth[SW_IPADDR]);
		if (reg.CreateKey(SENDORDER_STR))
		{
			for (i=0; i < MAX_SENDWIDTH; i++)
			{
				sprintf(buf, "%d", i);
				reg.GetInt(buf, &SendOrder[i]);
			}
			reg.CloseKey();
		}
		for (i=0; i < MAX_SENDWIDTH; i++)
		{
			if (SendOrder[i] >= MAX_SENDWIDTH || SendOrder[i] < 0)
				break;
			int i2;
			for (i2=i+1; i2 < MAX_SENDWIDTH; i2++)
				if (SendOrder[i] == SendOrder[i2])
					break;
			if (i2 != MAX_SENDWIDTH)
				break;
		}
		if (i != MAX_SENDWIDTH)
			for (i=0; i < MAX_SENDWIDTH; i++)
				SendOrder[i] = i;

		reg.GetInt(SENDXDIFF_STR, &SendXdiff);
		reg.GetInt(SENDYDIFF_STR, &SendYdiff);
		reg.GetInt(SENDMIDYDIFF_STR, &SendMidYdiff);
		reg.GetInt(SENDSAVEPOS_STR, &SendSavePos);
		reg.GetInt(SENDXPOS_STR, &SendXpos);
		reg.GetInt(SENDYPOS_STR, &SendYpos);

		reg.GetInt(RECVXDIFF_STR, &RecvXdiff);
		reg.GetInt(RECVYDIFF_STR, &RecvYdiff);
		reg.GetInt(RECVSAVEPOS_STR, &RecvSavePos);
		reg.GetInt(RECVXPOS_STR, &RecvXpos);
		reg.GetInt(RECVYPOS_STR, &RecvYpos);

		reg.GetInt(HISTXDIFF_STR, &HistXdiff);
		reg.GetInt(HISTYDIFF_STR, &HistYdiff);
		reg.GetInt(HISTUSER_STR, &HistWidth[HW_USER]);
		reg.GetInt(HISTODATE_STR, &HistWidth[HW_ODATE]);
		reg.GetInt(HISTSDATE_STR, &HistWidth[HW_SDATE]);
		reg.GetInt(HISTID_STR, &HistWidth[HW_ID]);

		reg.CloseKey();
	}

// Send/Recv Window Font
	if (reg.CreateKey(FONT_STR))
	{
		ReadFontRegistry(&reg, SENDEDITFONT_STR, &SendEditFont);
		ReadFontRegistry(&reg, SENDLISTFONT_STR, &SendListFont);
		ReadFontRegistry(&reg, RECVHEADFONT_STR, &RecvHeadFont);
		ReadFontRegistry(&reg, RECVEDITFONT_STR, &RecvEditFont);
		ReadFontRegistry(&reg, LOGVIEWFONT_STR, &LogViewFont);
		reg.CloseKey();
	}

// Broadcast Data
	if (reg.CreateKey(BROADCAST_STR))
	{
		i = 0;
		while (1)
		{
			sprintf(buf, "%d", i++);
			if (!reg.GetStr(buf, val, sizeof(val)))
				break;
			brList.SetHostRaw(val, (ResolveOpt & RS_REALTIME) ? 0 : ResolveAddr(val));
		}
		reg.CloseKey();
	}

// Clickable URL
	for (i=0; DefaultUrlProtocol[i]; i++)
	{
		UrlObj *obj = new UrlObj;
		strncpyz(obj->protocol, DefaultUrlProtocol[i], sizeof(obj->protocol));
		*obj->program = 0;
		urlList.AddObj(obj);
	}

	if (reg.CreateKey(CLICKABLEURL_STR))
	{
		for (i = 0; reg.EnumValue(i, buf, sizeof(buf)) || reg.EnumKey(i, buf, sizeof(buf)); i++)
		{
			UrlObj *obj;
			for (obj = urlList.TopObj(); obj; obj = urlList.NextObj(obj))
				if (stricmp(obj->protocol, buf) == 0)
					break;

			if (obj == NULL)
			{
				obj = new UrlObj;
				urlList.AddObj(obj);
			}
			strncpyz(obj->protocol, buf, sizeof(obj->protocol));
			reg.GetStr(buf, obj->program, sizeof(obj->program));
		}
		reg.CloseKey();
	}

// User Sort Priority
	if (reg.CreateKey(PRIORITY_STR))
	{
		reg.GetInt(PRIORITYMAX_STR, &PriorityMax);
		reg.GetInt(PRIORITYREJECT_STR, &PriorityReject);
#if 0
		PrioritySound = new char *[PriorityMax];
		for (int i=0; i < PriorityMax; i++)
		{
			sprintf(buf, "%d", i);

			if (reg.CreateKey(buf))
			{
				if (reg.GetStr(PRIORITYSOUND_STR, buf, sizeof(buf)) && *buf != '\0')
					PrioritySound[i] = strdup(buf);
				reg.CloseKey();
			}
		}
#endif
		reg.CloseKey();
	}

	if (reg.CreateKey(HOSTINFO_STR))
	{
		int		i = 0, priority = DEFAULT_PRIORITY;
		Host	*host;
		Time_t	default_time = Time() - KeepHostTime / 2;	// 90 日
		BOOL	rewriteFlg = FALSE;

		priorityHosts.Enable(THosts::NAME, TRUE);
		fileHosts.Enable(THosts::NAME_ADDR, TRUE);
		for (i = 0; reg.EnumValue(i, buf, sizeof(buf)) || reg.EnumKey(i, buf, sizeof(buf)); i++)
		{
			if (!reg.OpenKey(buf))
				break;

			BYTE	pubkey[512];
			int		pubkeySize = sizeof(pubkey);

			if (!reg.GetByte(PUBLICKEY_STR, pubkey, &pubkeySize)) pubkeySize = 0;

			if ((!reg.GetInt(PRIORITY_STR, &priority) || priority == DEFAULT_PRIORITY)
					&& pubkeySize == 0) {
				rewriteFlg = TRUE;
			}
			else {
				host = new Host;
				host->priority = priority;
				reg.GetStr(USERNAME_STR, host->hostSub.userName, MAX_NAMEBUF);
				reg.GetStr(HOSTNAME_STR, host->hostSub.hostName, MAX_NAMEBUF);
				reg.GetLong(IPADDR_STR, (long *)&host->hostSub.addr);
				reg.GetInt(PORTNO_STR, &host->hostSub.portNo);
				reg.GetStr(NICKNAME_STR, host->nickName, MAX_NAMEBUF);
				reg.GetStr(GROUPNAME_STR, host->groupName, MAX_NAMEBUF);
				reg.GetStr(ALTERNAME_STR, host->alterName, MAX_NAMEBUF);
				if (!reg.GetLong(UPDATETIME_STR, (long *)&host->updateTime)) {
					host->updateTime = default_time;
				}
				if (pubkeySize) {
					host->pubKey.UnSerialize(pubkey, pubkeySize);
// 古いエントリを削除にする処理は、一旦、様子見
//					char	*p = (char *)GetUserNameDigestField(host->hostSub.userName);
//					if (p) {
//						*p = 0;
//						Host *tmpHost = priorityHosts.GetHostByName(&host->hostSub);
//						if (tmpHost) {
//							priorityHosts.DelHost(tmpHost);
//							if (tmpHost->RefCnt() == 0) delete tmpHost;
//						}
//						*p = '-';
//					}
				}
				priorityHosts.AddHost(host);
			}
			reg.CloseKey();
		}
		reg.CloseKey();
		if (rewriteFlg) WriteRegistry(CFG_HOSTINFO|CFG_DELHOST);
	}

// Self private/public key (1024/2048)
	for (i=KEY_1024; i <= KEY_2048; i++) {
		const char *key = (i == KEY_1024) ? CRYPT_STR : CRYPT2_STR;
		int			need_blob_size = ((i == KEY_1024) ? 1024 : 2048) / 8 * 4;

		if (reg.CreateKey(key))
		{
			BYTE	key[MAX_BUF_EX];
			int		blen = sizeof(key);
			int		slen = sizeof(key);

			if (reg.GetByte(PRIVBLOB_STR, key, &blen) && blen > need_blob_size) {
				priv[i].SetBlob(key, blen);
			}
			if (reg.GetByte(PRIVSEED_STR, key, &slen)) {
				priv[i].SetSeed(key, slen);
			}
			reg.GetInt(PRIVTYPE_STR, &priv[i].encryptType);
			reg.CloseKey();
		}
	}

	if (reg.OpenKey(DEBUG_STR))	// 旧バージョンレジストリ削除
	{
		reg.CloseKey();
		reg.DeleteChildTree();
	}
	if (!reg.GetStr(NULL, buf, sizeof(buf)) || strcmp(buf, GetVersionStr()))
	{
		reg.CloseKey();		// close top appreg
		WriteRegistry();
	}

	return	TRUE;
}
Exemple #10
0
void Cfg::GetSelfRegName(char *buf)
{
	GetRegName(buf, nicAddr, portNo);
}