Register | Login
Forum Index > Projects > GuestMode plugin for HeXHub
Author Message
Pages: 1
RoLex
Ziron Beta Tester
(send private message)

Posts: 4
Topics: 2

Location:
Team Elite
[16] GuestMode plugin for HeXHub - posted: 2011-05-11 12:59:52
Here goes my first officially released HeXHub plugin, thanks to Meka][Meka for zIRON support and Lord_Zero for HeXHub plugin functions support.

Plugin functionality is very simple; As new non-registered user connects to your hub, his chat mode is automatically set to defined mode. You can define the mode using configuration dialog, which appears by clicking Configure plugin button, !set ext command is not supported yet, default mode is d. Defined mode is saved to GuestMode.ini in HeXHub root folder. For list of supported modes see Mode plugin for HeXHub.

Plugin itself;

Code:
program WIN32DLL 'AutoMode';

#cpu 486;

#include 'messages.zir';
#include 'ziron32.zir';
#include 'smm32.zir';
#include 'user32.zir';
#include 'kernel32.zir';
#include 'strutils.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;
  }

  ret;
}

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;
}

function LoadSettings {
  Ini_ReadString('.\\GuestMode.ini', @sMode, 'Main', 'Mode', 'd', 5);
  ret;
}

function SaveSettings {
  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;
}

function UnloadPlugin {
  SaveSettings;
  ret;
}

function GetAboutText {
  return sAbout;
}

function 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);
    }
  }

  EAX = xor;
  return true;
}

exports
  InitPlugin, UnloadPlugin, onNicklistChange, GetAboutText, GetConfig, SaveSettings;


Resource file;

The file was made using ResEd suggested by Lord_Zero, http://radasm.cherrytree.at/resed/, and compiled using Microsoft resource compiler.

Code:
#define IDR_VERSION 1
#define IDD_MODEDLG 1000
#define IDC_MODEBTN 1001
#define IDC_MODEEDT 1002
#define IDC_MODELBL 1003

#include "resource.h"

IDR_VERSION VERSIONINFO
FILEVERSION 0,1,0,0
PRODUCTVERSION 0,1,0,0
FILEOS 0x00000004
FILETYPE 0x00000002
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "FFFF04E4"
    BEGIN
      VALUE "FileVersion", "0.1.0.0\0"
      VALUE "ProductVersion", "0.1.0.0\0"
      VALUE "CompanyName", "Bulldozer™\0"
      VALUE "FileDescription", "Guest mode plugin written in Ziron\0"
      VALUE "InternalName", "GuestMode\0"
      VALUE "LegalCopyright", "© 2011 Bulldozer™\0"
      VALUE "OriginalFilename", "GuestMode.dll\0"
      VALUE "ProductName", "GuestMode\0"
      VALUE "Comments", "webmaster@feardc.net\0"
    END
  END
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0xFFFF, 0x04E4
  END
END

IDD_MODEDLG DIALOGEX 10,10,105,60
CAPTION "GuestMode"
FONT 8,"Tahoma",400,0,204
STYLE WS_VISIBLE|WS_CAPTION|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|DS_CENTER
BEGIN
  CONTROL "OK",IDC_MODEBTN,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,36,42,33,12
  CONTROL "d",IDC_MODEEDT,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,9,21,87,12,WS_EX_CLIENTEDGE
  CONTROL "Mode name",IDC_MODELBL,"Static",WS_CHILDWINDOW|WS_VISIBLE,9,9,39,9
END


Download;

http://hexadmins.strangled.net:4131/download/GuestMode01.zip

Mirror;

http://www.codeziron.com/uploads/projects/GuestMode01.zip

Happy zIRON coding! :-)

Team Elite | zIRON
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[17] - posted: 2011-05-11 13:21:32
Code:
entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
  if (iReason == DLL_PROCESS_ATTACH) {
    iHandle = iDLL;
    return true;
  }

  ret;
}


this function should return false like so

Code:
entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
  if (iReason == DLL_PROCESS_ATTACH) {
    iHandle = iDLL;
    return true;
  }

  return false;
}


you can optimise the return false if you like to

Code:
eax = xor;
ret


also this function

Code:
function onNicklistChange(DWord iUser; Boolean bAdded) {
  if (bAdded == true) {
    GetAccountId(iUser);

    if (EAX == 0) {
      SetMode(iUser, @sMode);
    }
  }

  EAX = xor;
  return true;
}


eax = xor; is not used, so you can remove it, else everything else is looking good, well done

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
RoLex
Ziron Beta Tester
(send private message)

Posts: 4
Topics: 2

Location:
Team Elite
[18] - posted: 2011-05-11 13:29:08
Thank you. Here goes an update of the source code.

GuestMode.zpr;

Code:
program WIN32DLL 'AutoMode';

#cpu 486;

#include 'messages.zir';
#include 'ziron32.zir';
#include 'smm32.zir';
#include 'user32.zir';
#include 'kernel32.zir';
#include 'strutils.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 {
  Ini_ReadString('.\\GuestMode.ini', @sMode, 'Main', 'Mode', 'd', 5);
  ret;
}

procedure SaveSettings {
  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;


GuestMode.rc;

Code:
#define IDR_VERSION 1
#define IDD_MODEDLG 1000
#define IDC_MODEBTN 1001
#define IDC_MODEEDT 1002
#define IDC_MODELBL 1003

#include "resource.h"

IDR_VERSION VERSIONINFO
FILEVERSION 0,1,0,0
PRODUCTVERSION 0,1,0,0
FILEOS 0x00000004
FILETYPE 0x00000002
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "FFFF04E4"
    BEGIN
      VALUE "FileVersion", "0.1.0.0\0"
      VALUE "ProductVersion", "0.1.0.0\0"
      VALUE "CompanyName", "Bulldozer™\0"
      VALUE "FileDescription", "Guest mode plugin written in zIRON\0"
      VALUE "InternalName", "GuestMode\0"
      VALUE "LegalCopyright", "© 2011 Bulldozer™\0"
      VALUE "OriginalFilename", "GuestMode.dll\0"
      VALUE "ProductName", "GuestMode\0"
      VALUE "Comments", "webmaster@feardc.net\0"
    END
  END
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0xFFFF, 0x04E4
  END
END

IDD_MODEDLG DIALOGEX 10,10,105,60
CAPTION "GuestMode"
FONT 8,"Tahoma",400,0,204
STYLE WS_VISIBLE|WS_CAPTION|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|DS_CENTER
BEGIN
  CONTROL "OK",IDC_MODEBTN,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,36,42,33,12
  CONTROL "d",IDC_MODEEDT,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,9,21,87,12,WS_EX_CLIENTEDGE
  CONTROL "Mode name",IDC_MODELBL,"Static",WS_CHILDWINDOW|WS_VISIBLE,9,9,39,9
END


Use the download URL in first post.

Team Elite | zIRON
RoLex
Ziron Beta Tester
(send private message)

Posts: 4
Topics: 2

Location:
Team Elite
[1377] Version 0.1.0.1 - posted: 2013-03-30 20:24:25
Nothing new actually, I only used latest assembler version 1.2.1.8 to recompile the plugin.

GuestMode.rc

Code:
// © 2011-2013 RoLex

#define IDR_VERSION 1
#define IDD_MODEDLG 1000
#define IDC_MODEBTN 1001
#define IDC_MODEEDT 1002
#define IDC_MODELBL 1003
#define WS_VISIBLE 0x10000000L
#define WS_CAPTION 0x00C00000L
#define WS_MINIMIZEBOX 0x00020000L
#define WS_MAXIMIZEBOX 0x00010000L
#define DS_CENTER 0x0800L
#define WS_CHILD 0x40000000L
#define WS_CHILDWINDOW (WS_CHILD)
#define WS_TABSTOP 0x00010000L
#define WS_EX_CLIENTEDGE 0x00000200L

LANGUAGE 0, 0

IDR_VERSION VERSIONINFO
FILEVERSION 0, 1, 0, 1
PRODUCTVERSION 0, 1, 0, 1
FILEOS 0x00000004
FILETYPE 0x00000002
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "FFFF04E4"
    BEGIN
      VALUE "FileVersion", "0.1.0.1\0"
      VALUE "ProductVersion", "0.1.0.1\0"
      VALUE "FileDescription", "Guest mode plugin for HeXHub written in zIRON\0"
      VALUE "InternalName", "GuestMode\0"
      VALUE "LegalCopyright", "© 2011-2013 RoLex\0"
      VALUE "OriginalFilename", "GuestMode.dll\0"
      VALUE "ProductName", "GuestMode\0"
      VALUE "Comments", "webmaster@feardc.net\0"
    END
  END
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0xFFFF, 0x04E4
  END
END

IDD_MODEDLG DIALOGEX 10, 10, 105, 60
CAPTION "GuestMode"
FONT 8, "Tahoma", 400, 0, 204
STYLE WS_VISIBLE | WS_CAPTION | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | DS_CENTER
BEGIN
  CONTROL "OK", IDC_MODEBTN, "Button", WS_CHILDWINDOW | WS_VISIBLE | WS_TABSTOP, 36, 42, 33, 12
  CONTROL "d", IDC_MODEEDT, "Edit", WS_CHILDWINDOW | WS_VISIBLE | WS_TABSTOP, 9, 21, 87, 12, WS_EX_CLIENTEDGE
  CONTROL "Mode name", IDC_MODELBL, "Static", WS_CHILDWINDOW | WS_VISIBLE, 9, 9, 39, 9
END

// end of file


GuestMode.zpr

Code:
// © 2011-2013 RoLex

program WIN32DLL 'GuestMode';

#cpu 486;
#include 'messages.zir';
#include 'user32.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-2013, RoLex';

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 {
  Ini_ReadString('.\\GuestMode.ini', @sMode, 'Main', 'Mode', 'd', 5);
  ret;
}

procedure SaveSettings {
  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;

// end of file


Download binary including source code from Team Elite website, HeXHub plugins directory, http://www.te-home.net/HeXHub/Plugins/GuestMode0101.zip, any questions are welcome.

Team Elite | zIRON
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1380] - posted: 2013-04-06 18:26:55
There was a few things i missed in the previous beta so I've corrected these problems. On the next beta release you will be able to compile your plugin in Ziron 2 as follows:

Code:
program PE32_DLL 'GuestMode';

#include 'win_def.zir';
#include 'zirutils.zir';
#include 'messages.zir';

#resource 'GuestMode.res';

function* WINAPI GetFunction(Pointer sFunc): Pointer;
function* WINAPI SetMode(DWord iUser; Pointer sMode): DWord;
function* WINAPI GetAccountId(DWord iUser): DWord;
function* WINAPI GetHubWindow: DWord;

const IDD_MODEDLG = 1000;
const IDC_MODEBTN = 1001;
const IDC_MODEEDT = 1002;
const sPlug = 'Guest mode plugin written in zIRON';
const sAbout = '2011-2013, RoLex';

DWord iHandle;
char sMode[8];

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) {
  eax = iMsg;
  
  if (eax == WM_COMMAND) {
    if (wPar == IDC_MODEBTN) {
      GetDlgItemText(iDlg, IDC_MODEEDT, @sMode, 4);
      EndDialog(iDlg, 0);
    }
  } elseif (eax == WM_CLOSE) {
    GetDlgItemText(iDlg, IDC_MODEEDT, @sMode, 4);
    EndDialog(iDlg, 0);
  } elseif (eax == WM_INITDIALOG) {
    SetDlgItemText(iDlg, IDC_MODEEDT, @sMode);
    ShowWindow(iDlg, SW_SHOWNORMAL);
  }

  return false;
}

procedure LoadSettings {
  GetPrivateProfileString('Main', 'Mode', 'd', @sMode, 5, '.\\GuestMode.ini');
}

procedure SaveSettings {
  WritePrivateProfileString('Main', 'Mode', @sMode, '.\\GuestMode.ini');
}

function InitPlugin(Pointer sFunc) {
  GetFunction = sFunc;
  SetMode = GetFunction('SetMode');
  GetAccountId = GetFunction('GetAccountId');
  GetHubWindow = GetFunction('GetHubWindow');
  LoadSettings;
  
  return sPlug;
}

procedure UnloadPlugin {
  SaveSettings;
}

function GetAboutText {
  return sAbout;
}

procedure GetConfig(DWord iParent) {
  DialogBoxParamA(iHandle, IDD_MODEDLG, iParent, @DialogFunc, 0);
}

function onNicklistChange(DWord iUser; Boolean bAdded) {
  if (bAdded == true) {
    eax = GetAccountId(iUser);

    if (eax == 0) {
      SetMode(iUser, @sMode);
    }
  }

  return true;
}

exports
  InitPlugin, UnloadPlugin, onNicklistChange, GetAboutText, GetConfig, SaveSettings;


Please note this will not compile with Ziron 2.0.0.3 beta or below

I hope to release a new beta in a short while.

some things can be optimized such as functions that do not contain any if statements or any type of jmps with pushes nested.

e.g.

Code:
procedure UnloadPlugin {
  SaveSettings;
}


you can tell the assembler to skip writing the stack frame like so:

Code:
#set frame off; //turn off frame
procedure UnloadPlugin {
  SaveSettings;
}
#set frame on; //turn frame back on so we don't run into any unexpected problems.


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 2 user(s) online. 0 member(s) and 2 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd