Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Source Help

Creating blocks, adding, deleting items

A community discussion post from the original code:zIRON forum.

RoLex member
Posts
4
Threads
2
Location
<a href="http://www.te-home.net/">Team Elite</a>

Creating blocks, adding, deleting items

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

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;

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?

[url=http://www.te-home.net/]Team Elite[/url] | [url=http://www.te-home.net/?do=work&id=ziron]zIRON[/url]

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Hi RoLex, ok your blocks are defined correctly, here is a small sample on using blocks

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.