I’m practicing network programming in C++ .Net. I figured a simple yahoo messenger login application would be a fun way to do this. Every example online is written in Visual Basic. I cannot find anything pertaining to yahoo chat, written in C++.
I found a really good example written in VB .NET which works. The example utilizes a .dll file for encrypting the username and password when logging into yahoo messenger. Below it the Visual Basic example of this function prototype.
This is my attempt at recreating this in C++.Net. I make a bogus call to the “YMSG12_ScriptedMind_Encrypt” function for testing purposes only.#Region "Private Externally Referenced Functions"
Private Declare Function YMSG12_ScriptedMind_Encrypt Lib "YMSG12ENCRYPT.DLL" (ByVal username As String, ByVal password As String, ByVal Seed As String, ByVal result_6 As String, ByVal result_96 As String, ByVal intt As int32) As Boolean
#End Region
When I run this code I get this error#include "stdafx.h"
#include "Form1.h"
#include "login.h"
#include <windows.h>
#include <string.h>
#include <iostream>
using namespace YAHOOLOGINC;
using namespace std;
typedef bool (WINAPI*cfunc)(std::string username, std::string password,
std::string Seed, std::string result_6,
std::string result_96, int intt);
cfunc YMSG12_ScriptedMind_Encrypt;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
HINSTANCE hMod = LoadLibrary("YMSG12ENCRYPT.DLL");
if(hMod==NULL)
MessageBox::Show("Unable to load dll");
YMSG12_ScriptedMind_Encrypt=(cfunc)GetProcAddress((HMODULE)hMod, "YMSG12_ScriptedMind_Encrypt");
//test call to the dll
bool test = YMSG12_ScriptedMind_Encrypt("hdhd", "dgdf", " ", " ", " ", 7);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
An unhandled exception of type 'System.AccessViolationException' occurred in YAHOOLOGINC++.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I’m not sure if this .dll can be used in a C++ app or if this has something to do with the CheckForIllegalCrossThreadCalls being set to true by defualt in VS 2005
I have attached a copy of this .dll file (YMSG12ENCRYPT.dll) and the VB.NET example.