Shoutbox

Force Plus to load - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: WLM Plus! General (/forumdisplay.php?fid=23)
+----- Thread: Force Plus to load (/showthread.php?tid=29642)

Force Plus to load by lopardo on 08-07-2004 at 08:59 PM

What does the "Force Messenger Plus! to load when computer starts" option really do? (Besides setting HKEY_LOCAL_MACHINE\SOFTWARE\Patchou\MsgPlus2\ForceLoad = 1).


RE: Force Plus to load by Ezra on 08-07-2004 at 09:02 PM

Sometimes plus! won't load before MSN, don't ask me why :P. And this makes sure, it always loads before MSN.

That's all I know :d


RE: Force Plus to load by lopardo on 08-07-2004 at 09:14 PM

What I mean is how does that work, how does it ensure Plus will load before Messenger?


RE: Force Plus to load by Ezra on 08-07-2004 at 09:15 PM

That's something I don't know :d


RE: Force Plus to load by lopardo on 08-07-2004 at 09:21 PM

Well, I asked this because I want to add a checkbox to my AppLoader program so you can easily enable/disable MsgPlus autorun at Windows startup (and open it whenever you want from AppLoader), and I didn't want to break anything. I guess just removing MsgPlus' key from the registry (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run) will work (it seems to be set by the installer).


RE: Force Plus to load by CookieRevised on 08-09-2004 at 03:17 PM

As you know, when you select "Automaticly run Messenger when I log on to Windows" in MSN Messenger, MSN Messenger adds a key to the registry:
=> HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
=> msnmsgr := "C:\Program Files\MSN Messenger\msnmsgr.exe" /background
This will make that MSN Messenger starts up when you start up Windows...
(note: this key is added each time Messenger starts up.*)

Also, when you've selected that "autorun"-option from Messenger, Messenger Plus! will delete the "msnmsgr"-key again and add its own key there when Messenger is closed:
=> MessengerPlus3 := "C:\Program Files\Messenger Plus! 3\MsgPlus.exe" /WinStart
(note: this key is added/replaced each time the process of Messenger ends (and Plus! is still running of course).*)

/WinStart makes that Messenger Plus! initialize first (like always) and then that it automaticly starts up MSN Messenger itself and hooks it.

If you don't use /WinStart, then Plus! wont start Messenger automaticly. But due the way that Windows handles the startup items, there is no way in making sure that Plus! is started before Messenger in that case.
In many situations this isn't realy a problem because most startup processes don't take long and Plus! will have enough time to hook into Messenger, even when it is started up after Messenger. But this is only true if there is a fraction of time between the two processes starting up, otherwise Plus! will give a "timeout" in the form of the recovery window.

Now, to make sure that Plus! tries to hook Messenger longer and more agressively (with more tries then normal), you can select the option "Force Plus! to load when computer starts" in Messenger Plus!.

This will set that registry key: ForceLoad := 1. Whenever Plus! is started up, it reads out that key and when it is true, it performs the "more agressive" method for hooking...



* because of this beheviour, you'll get a popup with a tool like StartupMonitor each time that Messenger starts (like every time you log into Windows) because it can find its key in to run-section (because plus! replaced it) and adds it again. And you'll get also a popup each time that Messenger quits because then Plus! removes the entry again... (given this, there is a workaround to this problem: just unselect the "autostartup"-option in Messenger and leave the Plus! entry (with /WinStart) in the run-section...)


EDIT: I hope, I've edited out the mistakes now


RE: Force Plus to load by Patchou on 08-09-2004 at 05:04 PM

Hum... you should edit your pot Cookie because you're not exactly right.

What you're describing with /Winstart is true, however, this behavuiour always occurs by default and has nothign to do with the recovery window. The /winstart method ensures Plus! is always loaded before Messenger when Windows starts (Plus! loads Messenger itself when it detects everything has been prepared).

The force option is here only in case of software malfunction. Some programs that are using hooks are not written properly and prevent other similar programs (like Plus!) to work properly. This happens if such program is loaded after Plus! is loaded and as Plus! tries its best to load as fast as possible, if you have such a defective program installed on your computer, you can be almost sure you'll get the problem.

The "force load" option tried to fix this problem by doing somethign very uncommon: it starts a timer and recreates its global hook every 5 seconds for a minute or so. That way, if another software hooks the syste unproperly while windows is starting, Plus! rehooks over it and the problem is solved. However, some systems may not like Plus! doing this kind of stuff and that'S why the force load option should be used only when it's necessary, it's not a toy to play with.

Hope it helps you,
Patchou


RE: Force Plus to load by cooldude_i06 on 08-09-2004 at 06:24 PM

Plus loads on my computer even when i have Diagnostic Startup selected.  Plus is the only program to start.


RE: Force Plus to load by CookieRevised on 08-10-2004 at 03:04 AM

quote:
Originally posted by Patchou
Hum... you should edit your pot Cookie because you're not exactly right.
I would like to, but realy don't know what or where as I realy can't see something wrong (asked on irc also, not much result)... please help (by editing it yourself maybe?)...
RE: Force Plus to load by Patchou on 08-10-2004 at 07:05 AM

What's wrong is that the Messenger key is always deleted and replaced wy a /WinStart Plus! one. It has nothing to do with the force load option :).


RE: Force Plus to load by CookieRevised on 08-10-2004 at 10:07 AM

oh I see, yeah... hmm... I drasticly edited my post now... I hope it's correct this time


RE: Force Plus to load by lopardo on 08-10-2004 at 09:17 PM

Thank you guys, it's very clear now :)

However, I've been doing some tests under a virtual machine with a clean Windows XP and noticed something:

I installed MSN Messenger 6.2 and then Plus. MSN Messenger set itself at startup in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run. Plus set itself at startup in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.

I closed MSN Messenger but Plus didn't replace the MSN Messenger startup key with the Plus one with "/WinStart" as expected.

I checked the registry, in HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger, AppSettings was = 62 00 00 80 (autorun disabled), but in the Options window it was enabled!
[Image: Image1.PNG]

When I clicked OK there, then it changed to 62 02 00 80 (autorun enabled) and when I closed MSN Messenger, Plus did what I expected it to do in the first place.
[Image: Image2.PNG]


So, my question is how does Plus read the AppSettings value to determine if MSN Messenger should start when Windows starts? Its value depends on many options (it's not always "62 00 00 80" for autorun disabled like in my case, it depends on the other options aswell).
Hope I was clear :)


RE: Force Plus to load by CookieRevised on 08-11-2004 at 01:32 PM

quote:
Originally posted by lopardo
So, my question is how does Plus read the AppSettings value to determine if MSN Messenger should start when Windows starts?
When Plus is started with /WinStart:
====================================
Plus! performs:
1) Unknown1 = RegGet(HKEY_CURRENT_USER\Software\Patchou\MsgPlus2\HandleMessengerStart)
AutoMsg4Start = RegGet(HKEY_CURRENT_USER\Software\Patchou\MsgPlus2\AutoMsg4Start)
AutoMsg5Start = RegGet(HKEY_CURRENT_USER\Software\Patchou\MsgPlus2\AutoMsg5Start)
2) When "AutoMsg5Start" or "AutoMsg4Start" has a value (the normal startup string) then Messenger is strarted up automaticly
3) Plus! process ends (?)...

.........
.........
You exit Messenger:

Nothing happens, because Plus! process was already stopped (?)...


When Plus is started without /WinStart
======================================
Plus! performs:
AppState = RegGet(HKEY_CURRENT_USER\Software\Microsoft\MessengerService\AppSettings)
ForceLoad = RegGet(HKEY_LOCAL_MACHINE\SOFTWARE\Patchou\MsgPlus2\ForceLoad)

.........
.........
You exit Messenger:

Plus! performs (explained in pseudo-code again):

MSNString = RegGet(HKCU\Software\Microsoft\Windows\CurrentVersion\Run\msnmsgr)
RegDelete(HKCU\Software\Microsoft\Windows\CurrentVersion\Run\MessengerPlus2)

Unknown1 = RegGet(HKCU\Software\Patchou\MsgPlus2\HandleMessengerStart)
Unknown2 = RegGet(HKCU\Software\Patchou\MsgPlus2\HandleMessengerStart)
/* meaning? and why twice? */

IF MSNString = NOT Empty THEN
  AppState = RegGet(HKCU\Software\Microsoft\MSNMessenger\AppSettings)
  IF CheckBit(AppState, 17) = 1 THEN
    RegSet(HKCU\Software\Microsoft\Windows\CurrentVersion\Run\MessengerPlus3, "c:\blah\msgplus.exe /Winstart")
    RegSet(HKCU\Software\Patchou\MsgPlus2\AutoMsg5Start, "c:\blah\msnmsgr.exe /background")
    /* (or "AutoMsg4Start", depending on what messenger version is used I assume) */
    RegDelete(HKCU\Software\Microsoft\Windows\CurrentVersion\Run\msnmsgr)
  END IF
ELSE
  IF RegGet(HKCU\Software\Patchou\MsgPlus2\AutoMsg5Start) = NOT Empty THEN
    AppState = RegGet(HKCU\Software\Microsoft\MSNMessenger\AppSettings)
    IF CheckBit(AppState, 17) = 1 THEN
      RegSet(HKCU\Software\Microsoft\Windows\CurrentVersion\Run\MessengerPlus3, "c:\blah\msgplus.exe /Winstart")
      RegDelete(HKCU\Software\Microsoft\Windows\CurrentVersion\Run\msnmsgr)
    ELSE
      RegDelete(HKCU\Software\Patchou\MsgPlus2\AutoMsg5Start)
    END IF
  END IF
END IF





these things can be found out with programs like Registry Monitor...


PS: There is also something about HKCU\Software\Patchou\MsgPlus2\HandleMessengerStart which is read after the "MessengerPlus2"-key is deleted, but I don't know why or what it's function is and I hadn't time yet to figure that out...


EDIT (3hours later:p): OK, I'll stop editing for now... It isn't easy to figure these things out, possible, but very confussing... my head hurts now :p Also, it seems complicated. And I don't know why all these things are performed. But there must be a reason. All this is just to show that Plus! does many things when Messenger is quit... It doesn't realy answer the question in a strait forward way, but I started this to try and answer it, and all this was the result... confussing isn't it :p
quote:
Originally posted by lopardo
So, my question is how does Plus read the AppSettings value to determine if MSN Messenger should start when Windows starts?
So, my second answer would be, it doesn't :p
It does do some checks and makes some changes when Messenger quits, and depending on that (HandleMessengerStart, AutoMsg4Start, AutoMsg5Start ?) it starts up Messenger the next time...
But is seems that when Plus! is started with /WinStart it doesn't perform all those checks....



Patchou, post your code instead, much easier :p ... nah... j/k



FYI: AppSettings consists of a some hexadecimal numbers indicating some general settings for MSN Messenger (eg: 62 0E 00 80):
=> if bit 1 of the second one (0E) is set (= bit 17 from the entire number, see above code), then MSN Messenger is started up when windows starts up and there should be an entry in the run-key. (eg: if it wasn't set in this example then the second number would be "0C")
=> if bit 5 of the first one (62) is set, then the option "open messenger main window when messenger starts" is selected also. (eg: if it wasn't set in this example then the first number would be "42"). Note that this bit is always set when bit 1 of second number is not set.
=> if bit 2 of the second one (0E) is set, then the option "allow automatic sign in when connected to the internet" is selected.
=> etc...
RE: Force Plus to load by CookieRevised on 08-11-2004 at 05:02 PM

quote:
Originally posted by lopardo
I installed MSN Messenger 6.2 and then Plus. MSN Messenger set itself at startup in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run. Plus set itself at startup in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.

That depends on if you install Plus! in a admin account, on a windows with multiple accounts, etc... I assume
RE: Force Plus to load by Patchou on 08-11-2004 at 05:50 PM

lol... you're right, here is the code :p. I think you found out pretty much everythign anyway. As for "HandleMessengerStart" it's just here as a user setting (how did you know about it? I don't remember giving this information publicly :). I added it in case someone wouldn't want Plus! to create it's own /Winstart key for some obscure technical reason.

code:
//
///////////////////////////////////////////////////////////////
void CMsgPlusUtilWnd::PreventAutoMessengerStart()
{
    try
    {
        TRACE("CMsgPlusUtilWnd::PreventAutoMessengerStart - called");

        //Removes Messenger from Windows starts and remember the command lines
        CRegKey reg;
        if(reg.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run")) == ERROR_SUCCESS)
        {
            TCHAR sPath[1024]; sPath[0] = '\0';
            ULONG nSize = 1024;
            reg.QueryStringValue(CPreferences::GetMessengerVersion() < 5 ? _T("MSMSGS") : _T("msnmsgr"), sPath, &nSize);
            reg.DeleteValue(_T("MessengerPlus2")); //Delete the old value

            CRegKey regMP;
            regMP.Create(HKEY_CURRENT_USER, _T("Software\\Patchou\\MsgPlus2"));
           
            DWORD nEnable = 1;
            regMP.QueryDWORDValue(_T("HandleMessengerStart"), nEnable);
            if(nEnable)
            {
                //First, check if we can do something here
                regMP.QueryDWORDValue(_T("HandleMessengerStart"), nEnable);
                if(sPath[0] == '\0')
                {
                    TCHAR sMPPath[1024]; sMPPath[0] = '\0';
                    DWORD nSize = 1024;
                    regMP.QueryStringValue(CPreferences::GetMessengerVersion() < 5 ? _T("AutoMsg4Start") : _T("AutoMsg5Start"), sMPPath, &nSize);
                    if(sMPPath[0] == '\0')
                        return;
                }

                //Check if Messenger is set to start automatically
                bool bMessengerStart = false;

                CRegKey regAdmin;
                DWORD nNotAdminMode = FALSE;
                if(regAdmin.Open(HKEY_CURRENT_USER, _T("Software\\Patchou\\MsgPlus2"), KEY_READ) == ERROR_SUCCESS)
                {
                    regAdmin.QueryDWORDValue(_T("NotAdminMode"), nNotAdminMode);
                    regAdmin.Close();
                }

                if(!nNotAdminMode)
                {
                    if(CPreferences::GetMessengerVersion() < 5)
                    {
                        CRegKey reg;
                        if(reg.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\MessengerService")) == ERROR_SUCCESS)
                        {
                            DWORD nAppSettings = 0;
                            reg.QueryDWORDValue(_T("AppSettings"), nAppSettings);
                            if(nAppSettings & 0x200)
                                bMessengerStart = true;
                        }
                    }
                    else
                    {
                        CRegKey reg;
                        if(reg.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\MSNMessenger")) == ERROR_SUCCESS)
                        {
                            DWORD nAppSettings = 0;
                            reg.QueryDWORDValue(_T("AppSettings"), nAppSettings);
                            if(nAppSettings & 0x200)
                                bMessengerStart = true;
                        }
                    }
                }

                //Add or remove our MP start value?
                if(bMessengerStart)
                {
                    //Add a special Messenger Plus! command line
                    string sMPCmdLine = _T("\"");
                    sMPCmdLine += CPreferences::GetMessengerPlusBinDir();
                    sMPCmdLine += _T("\\");
                    sMPCmdLine += CPreferences::GetMsgPlusExeName();
                    sMPCmdLine += _T("\" /WinStart");
                    reg.SetStringValue(_T("MessengerPlus3"), sMPCmdLine);

                    //Remember the path
                    if(sPath[0] != '\0')
                        regMP.SetStringValue(CPreferences::GetMessengerVersion() < 5 ? _T("AutoMsg4Start") : _T("AutoMsg5Start"), sPath);
                    reg.DeleteValue(CPreferences::GetMessengerVersion() < 5 ? _T("MSMSGS") : _T("msnmsgr"));
                }
                else
                    regMP.DeleteValue(CPreferences::GetMessengerVersion() < 5 ? _T("AutoMsg4Start") : _T("AutoMsg5Start"));
            }
            else
                reg.DeleteValue(_T("MessengerPlus3"));
        }
        TRACE("CMsgPlusUtilWnd::PreventAutoMessengerStart - exited");
    }
    catch(...)
    {
        TRACE("An exception was thrown in CMsgPlusUtilWnd::PreventAutoMessengerStart");
    }
}

RE: Force Plus to load by Dempsey on 08-11-2004 at 06:47 PM

:o Plus! source! :o


RE: Force Plus to load by Choli on 08-11-2004 at 09:06 PM

quote:
Originally posted by Patchou
As for "HandleMessengerStart" it's just here as a user setting (how did you know about it?
quote:
Originally posted by CookieRevised
these things can be found out with programs like Registry Monitor...
Patchou: a nice tool from sysinternals: http://www.sysinternals.com/ntw2k/source/regmon.shtml

Cookie: i don't have time now to read your pseudo-code nor patchou's code, so, could you send me a brief description of what HandleMessengerStart does? tnx;)
quote:
Originally posted by Dempsey
:o Plus! source! :o
it isn't the first time :P
RE: Force Plus to load by lopardo on 08-12-2004 at 04:44 AM

Great! Now I understand :)

This is for Delphi:
function IsMessengerAutostartEnabled: Boolean;
var
  reg: TRegistry;
  Buffer: DWORD;
begin
  Result := False;

  reg := TRegistry.Create;
  try
    reg.RootKey := HKEY_CURRENT_USER;

    if (reg.OpenKey('\Software\Microsoft\MSNMessenger',False)) then
    begin
      try
        if (reg.ReadBinaryData('AppSettings',Buffer,SizeOf(Buffer)) = 4) then
        begin
          Result := (Buffer and $0200 <> 0);
        end;
      except
      end;
    end;
  finally
    reg.Free;
  end;
end;

One last thing though, how did you know that option was 0x200?


RE: Force Plus to load by CookieRevised on 08-12-2004 at 08:38 AM

That's the easy part...

Select the option in Messenger, press ok, check the value in the registry...
Unselect the option in Messenger, press ok, check the value in the registry...
Compare the two....

;)