because that project is old, i have updated RoleX' code.
program WIN32DLL 'AutoMode';
#cpu 486;
#include 'messages.zir';
#include 'ziron32.zir';
#include 'smm32.zir';
#include 'zirutils.zir';
#include 'inifiles.zir';
#resource 'GuestMode.res';
function* GetFunction(Pointer sFunc): Pointer; stdcall;
function* SetMode(DWord iUser; Pointer sMode): DWord; stdcall;
function* GetAccountId(DWord iUser): DWord; stdcall;
function* GetHubWindow: DWord; stdcall;
const IDD_MODEDLG = 1000;
const IDC_MODEBTN = 1001;
const IDC_MODEEDT = 1002;
const sPlug = 'Guest mode plugin written in zIRON';
const sAbout = '2011, Bulldozer™';
DWord iHandle;
Char sMode[5];
entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
if (iReason == DLL_PROCESS_ATTACH) {
iHandle = iDLL;
return true;
}
return false;
}
function DialogFunc(DWord iDlg; DWord iMsg; DWord wPar; DWord lPar) {
if (iMsg == WM_COMMAND) {
if (wPar == IDC_MODEBTN) {
GetDlgItemText(iDlg, IDC_MODEEDT, @sMode, 4);
EndDialog(iDlg, 0);
}
} elseif (iMsg == WM_CLOSE) {
GetDlgItemText(iDlg, IDC_MODEEDT, @sMode, 4);
EndDialog(iDlg, 0);
} elseif (iMsg == WM_INITDIALOG) {
SetDlgItemText(iDlg, IDC_MODEEDT, @sMode);
ShowWindow(iDlg, SW_SHOWNORMAL);
}
return false;
}
procedure LoadSettings {
eax = Ini_ReadString('.\\GuestMode.ini', @sMode, 'Main', 'Mode', 'd', 5);
ret;
}
procedure SaveSettings {
eax = Ini_WriteString('.\\GuestMode.ini', 'Main', 'Mode', @sMode);
ret;
}
function InitPlugin(Pointer sFunc) {
GetFunction = sFunc;
SetMode = GetFunction('SetMode');
GetAccountId = GetFunction('GetAccountId');
GetHubWindow = GetFunction('GetHubWindow');
LoadSettings;
return sPlug;
}
procedure UnloadPlugin {
SaveSettings;
ret;
}
function GetAboutText {
return sAbout;
}
procedure GetConfig(DWord iParent) {
DialogBoxParamA(iHandle, IDD_MODEDLG, iParent, @DialogFunc, 0);
ret;
}
function onNicklistChange(DWord iUser; Boolean bAdded) {
if (bAdded == true) {
GetAccountId(iUser);
if (EAX == 0) {
SetMode(iUser, @sMode);
}
}
return true;
}
exports
InitPlugin, UnloadPlugin, onNicklistChange, GetAboutText, GetConfig, SaveSettings;
this i have compiled and it works correctly, a few changes have been made that prevented the older version from compiling.
1 thing to note is macros, any inline macro function returns whatever is returned from the macro
so
Ini_WriteString('.\\GuestMode.ini', 'Main', 'Mode', @sMode);
actually becomes
eax;
so by writing eax = ...., the eax = eax will never happen, therefore canceling it out.