What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Block Un-Wished Logins

Block Un-Wished Logins
Author: Message:
Pinecone
New Member
*

Avatar
Coffee Powered

Posts: 9
34 / Male / Flag
Joined: Dec 2008
RE: Block Un-Wished Logins
You can however hook into messenger and stop them just clicking the add contact button or whatever. I almost got it working, but for some reason it freezes the messenger main window after. I sent it to a friend of mine for testing and he didn't have the problem, so I'm unsure if it will work correctly for everyone or not. The point is, it stops them from adding contacts by clicking the add contact button or going through the menu. If anyone could provide any information on why this is freezing up my messenger, please respond to this post as i spent over 4 hours trying to figure it out to no avail.

code:
var WH_CBT = 5;
var HCBT_CREATEWND = 3;
var hHook;

function OnEvent_Initialize(MessengerStart) {
    hHook = Interop.Call('User32.dll', 'SetWindowsHookExW',
        WH_CBT,
        Interop.GetCallbackPtr('CBTProc'),
        Interop.Call('Kernel32.dll', 'GetModuleHandleW', 'MsgPlusLive.dll'),
        Interop.Call('Kernel32.dll', 'GetCurrentThreadId')
    );
}

function OnEvent_Uninitialize(MessengerExit) {
    if (hHook) Interop.Call('User32.dll', 'UnhookWindowsHookEx', hHook);
}

function CBTProc(nCode, wParam, lParam) {
    // MSDN said to simply return CallNextHook with no further processing if nCode<0
    if (nCode >= 0)
    // Check for notification of a window being created
    if (nCode == HCBT_CREATEWND) {
       
        // Is the window in question the add contact window
        if (GetClass(wParam) == 'MSNContacts_Dialog') {
           
            // Show Error message
            Interop.Call('User32.dll', 'MessageBoxW', 0, 'Erorr: You are not allowed to add a contact.', 0, 0x10);
           
            // MSDN says that returning anything other than 0 will stop the window being created.
            return 1;
               
        }
        // MSDN says that returning 0 allows the window to be created.
        return 0;
    }
   
    // Call next hook...
    return Interop.Call('User32.dll', 'CallNextHookEx', hHook, nCode, wParam, lParam);
}

// Returns the class name of hWnd
function GetClass(hWnd) {
    var Data = Interop.Allocate(0x200);
    Interop.Call('User32.dll', 'GetClassNameW', hWnd, Data, 0x200);
    var Class = Data.ReadString(0);
    Data.Size = 0;
    return Class;
}


This post was edited on 12-23-2008 at 06:52 PM by Pinecone.
12-23-2008 02:10 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Block Un-Wished Logins - by shallow on 12-22-2008 at 12:44 PM
RE: Block Un-Wished Logins - by Matti on 12-22-2008 at 12:57 PM
RE: Block Un-Wished Logins - by shallow on 12-22-2008 at 01:38 PM
RE: Block Un-Wished Logins - by Matti on 12-22-2008 at 07:27 PM
RE: Block Un-Wished Logins - by Pinecone on 12-23-2008 at 02:10 PM
RE: RE: Block Un-Wished Logins - by SmokingCookie on 12-28-2008 at 09:13 PM
RE: Block Un-Wished Logins - by Spunky on 12-28-2008 at 09:57 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On