Register | Login
Forum Index > Source Help > Creating blocks, adding, deleting items
Author Message
Pages: 1
RoLex
Ziron Beta Tester
(send private message)

Posts: 4
Topics: 2

Location:
Team Elite
[27] Creating blocks, adding, deleting items - posted: 2011-05-11 18:00:08
I'm trying to create a structure, a block in zIRON, and add / delete items in it.

Here is how HeXHub wants the structures to look;

plugins.txt
Code:
LPVOID GetConfigurationStringsTable(void);

If this function is exported, it should return the pointer to a table of pointers to configurable items, last item in this table must be -1 (0xFFFFFFFF).

A configurable item begins with a byte specifying its index (must be 1-based), followed by a NULL-terminated string with first word as configuration parameter accepted by !set followed by a description of that parameter. After the NULL terminator follows a list of structures as follows:

5) string:

typedef struct _string_str{
  BYTE  struct_id;  // for strings this is 115
  DWORD  data_ptr;  // pointer to data
  WORD  string_size;  // size of string
} string_str;

6) definition terminator:

typedef struct _term_str{
  BYTE  struct_id;  // if this is last structure in chain, this is -1
} term_str;

Last structure in chain must be 6). The plugin must preserve the configuration information between 2 calls of GetConfigurationStringsTable.


My plugin requires 2 blocks, number 5 and 6.

Here is my current construction;

Code:
block tConfStr {
  Byte iID;
  DWord iPointer;
  Word iSize;
}

block tConfTerm {
  Byte iID;
}

block tConfTable {
  tConfStr iStr;
  tConfTerm iTerm;
}


Is this the correct way to build a block of blocks? Also, how do I add new items and delete old items?

Team Elite | zIRON
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[28] - posted: 2011-05-11 18:41:17
Hi RoLex, ok your blocks are defined correctly, here is a small sample on using blocks

Code:
program WIN32CUI 'Sample';

#cpu 486;

#include 'smm32.zir'; //required to use new and delete
#include 'console.zir';

//declare our structures
block structA {
  DWord a;
}

block structB {
  structA struct;
  DWord b;
}


//declaring a static variable struct
structB mystruct;
mystruct.struct.a = 500;

WriteNumber(mystruct.struct.a);


//the more complex way is creating a new struct, using pointers etc
structB* mystruct2;

//allocate memory for this struct
mystruct2 = new structB;

//store the contents of edi until we finish using it
push edi; 

//move mystruct pointer to edi and use edi as structB
edi = mystruct2 as structB;

//assign 5000 to a
edi.struct.a = 5000;
edi.b = 5001;

//write the stored value, writenumber will use eax, ecx and edx hence we use edi
WriteNumber(edi.struct.a);
WriteNumber(edi.b);

//no longer use edi to access memory.
edi as nothing;

//restore the edi contents to before we used it
pop edi;

//deallocate mystruct2 memory
delete mystruct2;

Sleep(1000);
ExitProcess(0);


if you require further help, just let me know.

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 14 user(s) online. 0 member(s) and 14 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