How to calculate the MSN Messenger 6.x Passport user ID

MSN Messenger 6.x stores per Passport settings, so each account can have its own font colour, custom emoticons, display pictures, etc. These settings are located at HCU\Software\Microsoft\MSNMessenger\PerPassportSettings and %appdata%\Microsoft\MSN Messenger.

The file system settings include: custom emoticons, display pictures, backgrounds, list cache, winks, voice clips, deluxe display pictures, dynamic backgrounds and config cache for 6.0.

There are keys/sub folders representing each Passport that has been signed in, the name of these are a certain number which represents the account.

wtbw has reversed the hashing method and posted his findings on the forums, see there for full explainations.

Easy as 123 in C++:

int getUserId(LPTSTR user)
{
    unsigned int x = 0;

    for (int i = 0; i < strlen(user); i++) {
        x = x * 101;
        x = x + towlower(user[i]);
        }

    return x;
}

But in VB, a little more work is needed as there is no unsigned variable type:

Public Function getUserId(sSigninName As String) As Double

    Dim i As Integer

    For i = 1 To Len(sSigninName)
        getUserId = CToLong(getUserId * 101)
        getUserId = CToLong(getUserId + Asc(LCase(Mid$(sSigninName, i, 1))))

    Next i

End Function

Private Function CToLong(d As Double) As Double

    CToLong = d

    Do While CToLong > 2 ^ 32
        CToLong = CToLong - 2 ^ 32
    Loop

End Function

For the convenience, here is how to get the application data directory:

Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long

Public Const CSIDL_APPDATA = &H1A

Public Type SHITEMID
    cb As Long
    abID As Byte
End Type

Public Type ITEMIDLIST
    mkid As SHITEMID
End Type

Public Function GetDataFolder() As String

    Dim sPath As String * 512
    Dim IDL As ITEMIDLIST

    Call SHGetSpecialFolderLocation(0, CSIDL_APPDATA, IDL)
    Call SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath)
    GetDataFolder = Left$(sPath, InStr(sPath, Chr$(0)) - 1)

End Function

You can also use the %appdata% environment variable, but it doesn’t seem to be available on 9x based systems.

0 Response to “How to calculate the MSN Messenger 6.x Passport user ID”


Comments are currently closed.