PDA

View Full Version : Free Plugin : Memory Plugin


AMSWaves
07-29-2009, 07:56 AM
Hi All,
Im back, in this long period im working on some plugin & Program and now im back, for today i create memory plugin And im work on OpenGL Plugin for AMS.

this plugin very very useful for advanced Programmers and less useful for beginners.

usages :

1) all body know call a functions in dll can be in 2 way by value and by refrence and some dll just use second way for calling or returning (Like GetWindowTextA in user32.dll or ...) with this plugin u can call a dll with refrence. :) (See help file and second attachment)

2) with this plugin you can create Plugin :huh, With this & useful tool from reteset (http://indigorose.com/forums/showthread.php?t=27283) you can create powerful Plugin for Example with this i create Clipboard plugin see third attachment. but if you create a plugin with this plugin you MUST write a THANKS to the author of this plugin for create this.:);) (this is something like a copyright)

3) if you create a dll that have a string parameter use memory instead of string, use it better.

4) with this u can create relevance between two or more application that you want create.

5) for beginners this can handle (store) any thing on memory (number or string) but be aware after close application all memory poped, be carful.

With these plugins AMS come powerful.
First Attachment is Setup file.

Enjoy.:)

Please Reply:yes

Tomasin
07-30-2009, 04:34 AM
hi

thanks for the plugin :yes

with this its possible create one ramcleaner?

works in systems 64 bits?

thanks

AMSWaves
07-30-2009, 09:10 AM
hi

thanks for the plugin :yes


hi Tomasin, thanks for reply



with this its possible create one ramcleaner?


no this plugin created for your application, with this plugin you just can free and clean size of ram that your application before allocated.



works in systems 64 bits?


i dont know i must install a 64 bit os for my plugins, my plugins created for 32 bit os maybe my plugins in 64 bit os maybe plugins want some optimizing in functions and variable ..., but maybe work.

ShadowUK
07-30-2009, 12:53 PM
The plugin worked fine on Windows 7 x64.

reteset
08-01-2009, 05:20 PM
Great Job , thank you for this good tool
i was trying this , but it always crashes

what is wrong in this function


function GetPluginNameFromLMD(strPath)

memSz = Memory.Allocate(1024);
memPn = Memory.Allocate(8);
Memory.PutInt(memSz, 0);
Memory.PutString(memPn, "", -1);


DLL.CallFunction(strPath, "irPlg_GetPluginName", memPn..","..memSz, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
memPn = Memory.ReAllocate(memPn, memSz);

nlegth = Memory.GetInt(memSz);
DLL.CallFunction(strPath, "irPlg_GetPluginName", memPn..","..nlegth, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);

local strPluginName = Memory.GetString(memPn, -1);
Memory.Free(memSz);
Memory.Free(memPn);
return strPluginName;
end

this will call the function below ( you know)
int irPlg_GetPluginName(char* szBuffer, int* pnBufferSize)
{

int nLength = lstrlen(szObjectName);
if(*pnBufferSize < nLength)
{
*pnBufferSize = nLength;
return -1;
} else
{
memset(szBuffer,0,*pnBufferSize);
lstrcpy(szBuffer,szObjectName);
return nLength;
}
}

in first call of this funtion , it returns the buffer size with pnBufferSize
and in second call of this function i use pnBufferSize as the buffer size and i'll get szBuffer as plugin name ,
but it fails always even if i tried different variations



thanks

AMSWaves
08-01-2009, 06:24 PM
Great Job , thank you for this good tool
i was trying this , but it always crashes

what is wrong in this function


function GetPluginNameFromLMD(strPath)

memSz = Memory.Allocate(1024);
memPn = Memory.Allocate(8);
Memory.PutInt(memSz, 0);
Memory.PutString(memPn, "", -1);


DLL.CallFunction(strPath, "irPlg_GetPluginName", memPn..","..memSz, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
memPn = Memory.ReAllocate(memPn, memSz);

nlegth = Memory.GetInt(memSz);
DLL.CallFunction(strPath, "irPlg_GetPluginName", memPn..","..nlegth, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);

local strPluginName = Memory.GetString(memPn, -1);
Memory.Free(memSz);
Memory.Free(memPn);
return strPluginName;
end

this will call the function below ( you know)
int irPlg_GetPluginName(char* szBuffer, int* pnBufferSize)
{

int nLength = lstrlen(szObjectName);
if(*pnBufferSize < nLength)
{
*pnBufferSize = nLength;
return -1;
} else
{
memset(szBuffer,0,*pnBufferSize);
lstrcpy(szBuffer,szObjectName);
return nLength;
}
}

in first call of this funtion , it returns the buffer size with pnBufferSize
and in second call of this function i use pnBufferSize as the buffer size and i'll get szBuffer as plugin name ,
but it fails always even if i tried different variations



thanks

hi my brother, i felt good to see you in this thread :):):), i think nobody love this plugin but this is very powerful, you know.
i think we must use this plugin more to all body know what is this.



use this function i change and improve it with comment see it :
function GetPluginNameFromLMD(strPath)

memPn = Memory.Allocate(1024); -- memory for store plugin name
memSz = Memory.Allocate(8); -- memory for store memPn size
Memory.PutInt(memSz, 1024); -- Size of memPn
--Memory.PutString(memPn, "", -1); all memory have null value dont need this line


ret = tonumber(DLL.CallFunction(strPath, "irPlg_GetPluginName", memPn..","..memSz, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL))

if ret == -1 then -- size of memPn is not enough so dll fill the require size in memSz
require_size = Memory.GetInt(memSz) -- get the require size that dll filled it
memPn = Memory.ReAllocate(memPn, require_size); -- reallocate memPn with require size
DLL.CallFunction(strPath, "irPlg_GetPluginName", memPn..","..memSz, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
end

local strPluginName = Memory.GetString(memPn, -1); -- get the plugin name
Memory.Free(memSz); -- release memory on ram of memSz
Memory.Free(memPn); -- release memory on ram of memPn
return strPluginName; -- return :)
end

if u see bug please post it, your post really create me happy for this plugin.:):):):yes

thanks.

AMSWaves
08-01-2009, 07:35 PM
this is better call irPlg_GetPluginName with DLL_CALL_CDECL instead of DLL_CALL_STDCALL because these are c function, so with DLL_CALL_CDECL dll return correct value (-1 for not enough memory size chek it with irPlg_GetPluginActionXML because this want big memory.)

so correction code is :
function GetPluginNameFromLMD(strPath)

memPn = Memory.Allocate(1024); -- memory for store plugin name
memSz = Memory.Allocate(8); -- memory for store memPn size
Memory.PutInt(memSz, 1024); -- Size of memPn
--Memory.PutString(memPn, "", -1); all memory have null value dont need this line


--ret = tonumber(DLL.CallFunction(strPath, "irPlg_GetPluginActionXML", memPn..","..memSz, DLL_RETURN_TYPE_INTEGER, DLL_CALL_CDECL))
ret = tonumber(DLL.CallFunction(strPath, "irPlg_GetPluginName", memPn..","..memSz, DLL_RETURN_TYPE_INTEGER, DLL_CALL_CDECL))

if ret == -1 then -- size of memPn is not enough so dll fill the require size in memSz
require_size = Memory.GetInt(memSz) -- get the require size that dll filled it
memPn = Memory.ReAllocate(memPn, require_size); -- reallocate memPn with require size
--ret = tonumber(DLL.CallFunction(strPath, "irPlg_GetPluginActionXML", memPn..","..memSz, DLL_RETURN_TYPE_INTEGER, DLL_CALL_CDECL))
DLL.CallFunction(strPath, "irPlg_GetPluginName", memPn..","..memSz, DLL_RETURN_TYPE_INTEGER, DLL_CALL_CDECL);
end

local strPluginName = Memory.GetString(memPn, -1); -- get the plugin name
Memory.Free(memSz); -- release memory on ram of memSz
Memory.Free(memPn); -- release memory on ram of memPn
return strPluginName; -- return :)
end

Imagine Programming
08-01-2009, 07:42 PM
I'm loving this plugin, memory support for AMS yay !

I must thank you alot AMSWaves, very well done! :yes

Imagine Programming
08-01-2009, 07:48 PM
Here's one to get the plugin's XML

:D

this is mighty!

function GetPluginXMLFromLMD(strPath)
local memPx = Memory.Allocate(1024);
local memSz = Memory.Allocate(8);
Memory.PutInt(memSz, 1024);

local ret = tonumber(DLL.CallFunction(strPath, "irPlg_GetPluginActionXML", memPx..","..memSz, DLL_RETURN_TYPE_INTEGER, DLL_CALL_CDECL))

if ret == -1 then
local require_size = Memory.GetInt(memSz)
memPx = Memory.ReAllocate(memPx, require_size);
DLL.CallFunction(strPath, "irPlg_GetPluginActionXML", memPx..","..memSz, DLL_RETURN_TYPE_INTEGER, DLL_CALL_CDECL);
end

local strPluginXML = Memory.GetString(memPx, -1);
Memory.Free(memSz);
Memory.Free(memPx);
return strPluginXML;
end

reteset
08-02-2009, 12:32 PM
Thank You , It works Perfect :yes

most of the people can think , this is a useless tool
but they are missing a big thing ;)


this is really a useful plugin , but it requires a bit of high level knowledge

i was trying to make a dialog for Action Plugin Compiler that lists installed actions plugins
like the attahment below , it works well now

thank you very much

MicroByte
08-02-2009, 04:38 PM
Nice Work, This is very powerful and now enables AMS to use even more API as well as many other 3rd party dll's that use memory pointers.

Thanks

Centauri Soldier
08-02-2009, 04:48 PM
This seems like a very powerful plugin but I wouldn't even know where to begin learning how to use it or to what application I would apply it. I know diddly about memory management.

S0mbre
08-02-2009, 11:21 PM
Thank you man for this rockin plugin! now it's time to tweak it with AMS, eh? a lil bit of c++ functionality won't do no harm to it :)

AMSWaves
08-03-2009, 07:23 PM
Hi All,
Thanks Imagine Programming, reteset, MicroByte, Centauri Soldier, S0mbre and all members for your attention.

AMSWaves
08-03-2009, 07:25 PM
Thank You , It works Perfect :yes

most of the people can think , this is a useless tool
but they are missing a big thing ;)


this is really a useful plugin , but it requires a bit of high level knowledge

i was trying to make a dialog for Action Plugin Compiler that lists installed actions plugins
like the attahment below , it works well now

thank you very much

This is pretty Dialog;):D

Good Work.

AMSWaves
08-03-2009, 07:31 PM
This seems like a very powerful plugin but I wouldn't even know where to begin learning how to use it or to what application I would apply it. I know diddly about memory management.

maybe i can say some story from memory management and some help file for work with windows api in tomorrow.

AMSWaves
08-04-2009, 03:00 PM
i create this help to all body know work of memory, sorry for bad writing if you have any problem or any question please feel free to post it, i really love to speak around memory and problems;):).
Thanks.
First :

for fist thing you can create a memory Pointer with:

memptr = Memory.Allocate(256) -- 256 is size of my memory


and you can put on it some value with :

Memory.PutString()
Memory.PutByte()
Memory.PutChar()
Memory.PutDouble()
Memory.PutFloat()
Memory.PutInt()
Memory.PutLong()
Memory.PutInt64()
Memory.PutShort()



and you can get value from memory with :

Memory.GetString()
Memory.GetByte()
Memory.GetChar()
Memory.GetDouble()
Memory.GetFloat()
Memory.GetInt()
Memory.GetLong()
Memory.GetInt64()
Memory.GetShort()



if size of your memory is not enough u can increase or decrease your memory size with :

memptr = Memory.ReAllocate(memptr, 1024) -- old size is 256 bytes and new is 1024 bytes



you can get the size of your memory with :

size_of_memptr = Memory.Size(memptr) -- before Memory.ReAllocate size is 256 and after is 1024



you fill all memory byte with null value (this is some times needed for password buffer) with :

Memory.Zero(memptr)



and you can copy and move one memory to another memory with :

Memory.Move()
Memory.Copy()



Compare two memories and get size in string and byte mode is possible with :

Memory.Compare()
Memory.CompareString()
Memory.Size()
Memory.SizeString()



you can append one string in the end of your memory with :

Memory.CopyString()



and at the end you must free, release or kill memory on ram with :

Memory.Free()




Second :

for Second thing you must know memory pointer is like a variable :


a = 10 -- create a number varialbe in AMS
Dialog.Message("value in Variable a", a)




a = Memory.Allocate(256) -- create a memory pointer (like varialbe a ) in Memory Plugin
Memory.PutInt(a, 10)

Dialog.Message("memory Pointer a", a)
Dialog.Message("value in memory Pointer a", Memory.GetInt(a, 10))


these two code dont have any difference, in second code 'a' is a pointer of block of memory in ram
that you can put in it everything with Memory.Put*** Functions.


Third :

in c++ when you create a pointer value you allude to a number that stored in memory for examp 9754654
this number is start of your memory block in ram.


ptr *pointer -- create pointer as Memory Pointer like pointer = Memory.Allocate(some size)
int a = 10 -- a = 10

pointer = &a -- this is not possible in AMS because AMS variable dont have Pointer but you can
-- fill Pointer memory with Memory.PutInt(pointer, a).

Cout << *pointer -- Debug value of Pointer (10) like Memory.GetInt(pointer)
Cout << pointer -- Debug number of pointer (ex : 9754654) like Debug.Print(pointer)



Fourth :

Memory.Allocate() return a number like 9754654, this number mean start of your memory block so you
can walk on it for examp :



mem = Memory.Allocate(1024)
txt = "AMSWaves"

Memory.PutString(mem, txt, -1)

Dialog.Message("Print value in memory", Memory.GetString(mem, -1))

Memory.Free(mem)




mem = Memory.Allocate(1024)
txt = "AMSWaves"

for i = 0, String.Length(txt)-1 do
t = String.Mid(txt, i+1, 1) -- one by one char from txt
Memory.PutByte(mem + i, String.Asc(t))
end

Dialog.Message("Print value in memory", Memory.GetString(mem, -1))

Memory.Free(mem)



these two Code dont have any difference, in first code we put 'AMSWaves' with Memory.PutString()
in memory and in second code we put 'AMSWaves' with walking in memory (mem + i) and put one byte
one byte on that pointer

see better Work of Second Code, if we think mem is 9754654 for examp so we have :

mem + 0 = 9754654 -- first byte of pointer 'A'
mem + 1 = 9754655 -- second byte of pointer 'M'
mem + 2 = 9754656 -- third byte of pointer 'S'
mem + 3 = 9754657 -- fourth byte of pointer 'W'
mem + 4 = 9754658 -- 5th byte of pointer 'a'
mem + 5 = 9754659 -- 6th byte of pointer 'v'
mem + 6 = 9754660 -- 7th byte of pointer 'e'
mem + 7 = 9754661 -- 8th byte of pointer 's'


walk on memory is a good method for encrypting decripting & compressing uncompressing data,
for copy a file on memory and use it (one byte one byte), for download a file on memory and
then use it and everything you can think with memory possible, we just want know what we want do
with memory.


5th :
memory pointer have a refrence so you can send it to a dll and dll work on it then u get the value.
So you can call more API as well as many other 3rd party dll's.

For examp these api work with refrence :

CreateFileA ---> kernel32.dll
ReadFile ---> kernel32.dll
WriteFile ---> kernel32.dll
ReadFile ---> kernel32.dll
GetWindowTextA ---> user32.dll
.
.
.
.

and very very much api that u can use in AMS.
u can use 3rd party dll's that uses pointer memory or refrence.

for see api help u can go to my site and download Platform SDK (~385 MB) or windows help(~5.4 MB)
Platform SDK is very usefull for api programming but windows help is limited and old.

Address :
http://www.amswaves.com/PSDK/

Note :
some variable name have type, if you see below type in the help api you must know that are pointer

following are Pointers (Memory adresses to Variables)
************************************************** ***************

LPBOOL Pointer to a BOOL.
LPBYTE Pointer to a BYTE.
LPCOLORREF Pointer to a COLORREF value.
LPCSTR Pointer to a constant String.
LPCTSTR An LPCWSTR if UNICODE is defined, an LPCSTR otherwise.
LPCVOID Pointer to a constant of any type.
LPCWSTR Pointer to a constant string of 16-bit Unicode characters.
LPDWORD Pointer to a DWORD.
LPHANDLE Pointer to a HANDLE.
LPINT Pointer to an INT.
LPLONG Pointer to a LONG.
LPSTR Pointer to a string
LPTSTR An LPWSTR if UNICODE is defined, an LPSTR otherwise.
LPVOID Pointer to any type.
LPWORD Pointer to a WORD.
LPWSTR Pointer to a string of 16-bit Unicode characters.
PBOOL Pointer to a BOOL.
PBOOLEAN Pointer to a BOOL.
PBYTE Pointer to a BYTE.
PCHAR Pointer to a CHAR.
PCSTR Pointer to a string
PCTSTR A PCWSTR if UNICODE is defined, a PCSTR otherwise.
PCWCH Pointer to a constant WCHAR.
PCWSTR Pointer to a constant string of 16-bit Unicode characters.
PDWORD Pointer to a DWORD.
PFLOAT Pointer to a FLOAT.
PHANDLE Pointer to a HANDLE.
PHKEY Pointer to an HKEY.
PINT Pointer to an INT.
PLCID Pointer to an LCID.
PLONG Pointer to a LONG.
PLUID Pointer to a LUID.
POINTER_32 32-bit pointer.
POINTER_64 64-bit pointer. On a 64-bit system, this is a native pointer. On a 32-bit system, this is a sign-extended 32-bit pointer.
PSHORT Pointer to a SHORT.
PSTR Pointer to a string
PTBYTE Pointer to a TBYTE.
PTCHAR Pointer to a TCHAR.
PTSTR A PWSTR if UNICODE is defined, a PSTR otherwise.
PUCHAR Pointer to a UCHAR.
PUINT Pointer to a UINT.
PULONG Pointer to a ULONG.
PUSHORT Pointer to a USHORT.
PVOID Pointer to any type.
PWCHAR Pointer to a WCHAR.
PWORD Pointer to a WORD.
PWSTR Pointer to a string of 16-bit Unicode characters.

************************************************** ***************


you must know for now memory plugin not support Unicode, in future.

Centauri Soldier
08-04-2009, 05:26 PM
WOW! Thank you very much, that was quite detailed. I can see how it would be beneficial to set aside memory for instances such as databases and the like. I imagine one would be able to help prevent stack overflows with such a tool.

Imagine Programming
08-04-2009, 08:22 PM
Nice work AMSWaves, great tutorial.

AMSWaves
08-05-2009, 09:21 AM
Thanks good to see this tutorial have benefit.:):):)

AMSWaves
08-10-2009, 02:58 PM
Hi all,
in last week i post a example Downlaod File To Memory on Example section but now see that not exist:wow

This Example show power of memory plugin, with this example you see how you can download a file from internet to your memory and then use it, you can download files on memory then use it as text or create a file of it and then use it and then kill memory so user can not see your downloaded files (For Security reason).
Use and Enjoy.

AMSWaves
08-13-2009, 11:21 AM
Hi All, in these days that im absent im work on Memory Plugin and some security way that Post it on future, i find bad bogs on GetIn64 & PutInt64 And GetString & PutString and fixed it, and now plugin support unicode and utf8 and ascii (see help file).

So Changes is :


Bug Fix in Memory.GetString() and Memory.PutString()
Memory.GetString() and Memory.PutString() now support Ascii, Unicode And UTF8
Bug Fix in Memory.GetInt64() and Memory.PutInt64(), these funcs now use string instead of number


Some Info On Bug Fix in Memory.GetInt64() and Memory.PutInt64(), these funcs now use string instead of number for programmer and developer :

AMS & Lua number variable really cant handle big numbers (Int64) for examp :

int64_number = 9876974526712182279
Dialog.Message("", int64_number) -- Print 9.8769745267122e+018 :wow

so every body want handle big numbers use string instead of number variable

Enjoy:yes

AMSWaves
08-25-2009, 05:36 PM
Hi all
New Version Released v 1.0.2.0
this version just have a minor bug fix on Memory.PutString() and Memory.GetString() but for those that want work with ut8 and unicode this version is very important.

Enjoy!

Imagine Programming
08-25-2009, 06:21 PM
Hi all
New Version Released v 1.0.2.0
this version just have a minor bug fix on Memory.PutString() and Memory.GetString() but for those that want work with ut8 and unicode this version is very important.

Enjoy!

Thanks AMSWaves, much appreciated.

kjh
08-28-2009, 08:16 AM
Hi AMSWaves
Thanks for the great Memory-plugin

I have tried to get your sample (Download File To Memory.apz) to work but it seems that an update is needed.
The Memory.PutString mode parameter is missing in the function DownloadToMemory().

I have tried all Memory.PutString mode's and different download destinations but the function keeps returning size==-1.

Question:
Can I use the agent string in the sample or do I have to change it to my own values?

-- Memory.PutString(agent, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.2", -1,"Ascii")

I'm running XP SP3 if that is relevant?

Thanks in advance

AMSWaves
08-28-2009, 03:38 PM
Hi AMSWaves
Thanks for the great Memory-plugin

I have tried to get your sample (Download File To Memory.apz) to work but it seems that an update is needed.
The Memory.PutString mode parameter is missing in the function DownloadToMemory().

I have tried all Memory.PutString mode's and different download destinations but the function keeps returning size==-1.


hi kjh and thanks.
i test it with new version of plugin good worked just want some changes in (mode's that you said) download this again and test it.



Can I use the agent string in the sample or do I have to change it to my own values?

-- Memory.PutString(agent, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.2", -1,"Ascii")

I'm running XP SP3 if that is relevant?

Thanks in advance

you can change it to anything you want i just write it for example (i copy it from latest firefox 3.5.2) but you must know windows sent this agent to site that you connected to it for download so is better write it a real agent name but any way anything you want.

rexzooly
10-01-2009, 01:22 PM
hi kjh and thanks.
i test it with new version of plugin good worked just want some changes in (mode's that you said) download this again and test it.




you can change it to anything you want i just write it for example (i copy it from latest firefox 3.5.2) but you must know windows sent this agent to site that you connected to it for download so is better write it a real agent name but any way anything you want.

Cant download Picture file your demo just keeps saying this on windows 7.

AMSWaves
10-01-2009, 08:19 PM
realy i dont know, i use InternetOpenA api in wininet.dll, maybe on win7 this api want some change, also not worked on win Vista ?

jassing
10-01-2009, 08:42 PM
Cant download Picture file your demo just keeps saying this on windows 7.

does the same thing for me on Winxp sp3....even changed to an image on a local intranet server...

AMSWaves
10-04-2009, 12:41 PM
Hi All this is a new version of Memory Plugin.
in this new version you can create a structure like Clike programming langs and use it in many api that want structure but create Structure is beta and for now not support Strings and want some changes still, So please test it with any structure you know and say any bugs.

Changes :

New Methods For Support Sructures!
New Functions are .CreateStructure, .SetStructureData, .GetStructureData, .FreeStructure .


thanks for your testing and suggest.

Best Regards,
AMSWaves.

RizlaUK
10-04-2009, 02:15 PM
shocking, structures in AMS, i'll drop everything and test this right now

nice work :yes

RizlaUK
10-04-2009, 02:30 PM
works with RECT :yes

-- create RECT Structure that have 4 long or int fields
local Struct = Memory.CreateStructure("int, int, int, int")

DLL.CallFunction("user32.dll", "GetWindowRect", Application.GetWndHandle()..",".. Struct, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);

local rc={}

rc.left = Memory.GetStructureData(Struct, 1)
rc.top = Memory.GetStructureData(Struct, 2)
rc.right = Memory.GetStructureData(Struct, 3)
rc.bottom = Memory.GetStructureData(Struct, 4)

strText="Left:"..rc.left.."\r\n"
strText=strText.."Top:"..rc.top.."\r\n"
strText=strText.."Right:"..rc.right.."\r\n"
strText=strText.."Bottom:"..rc.bottom.."\r\n"

result = Dialog.Message("Notice", strText, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

Memory.FreeStructure(Struct)

RizlaUK
10-06-2009, 04:03 PM
man, this structure system is amazing, do you guys have any idea how much this opens AMS up, you wouldn't beleave the things im doing here!

johnraus
10-06-2009, 04:21 PM
man, this structure system is amazing, do you guys have any idea how much this opens AMS up, you wouldn't beleave the things im doing here!

could you giv us an example .... seeing is better than believing ;)

RizlaUK
10-06-2009, 05:23 PM
sure, in a few days i will post a mega example of what this plugin can do, but im showing no code now as it will give the game away, lets just say, iv achieved my goals in AMS ;)

DaSoulRed
10-08-2009, 09:27 AM
That post sounds Cool...

keep your effort... i will have new goals... u will see... new Puzzles will arrive...

Enjoy... :)

Bytes for Now

DaSoulRed
10-09-2009, 09:12 AM
That post sounds Cool...

keep your effort... i will have new goals... u will see... new Puzzles will arrive...

Enjoy... :)

Bytes for Now

keep your effort... "YOU" will have new goals... u will see... new Puzzles will arrive...

Enjoy... :) <-- I MEAN YOU WILL

AMSWaves
10-09-2009, 05:15 PM
Hi All.
thanks RizlaUk and all body that know the power of Memory plugin, i decide to improve this plugin so improve structures methods and add new methods for creating array (but just support One Dimension array).
i think all body know about arrays array is something like Lua tables but array can used in some apis, so i think now all body can work with all apis in windows.

Changes :

New Methods For Support Arrays!
New Functions are .CreateArray, .SetArrayData, .GetArrayData, .FreeArray.
Structures Methods improved and have some changed
Now Structures Methods support multi fields (like int[12] instead of int, int, ...)


Enjoy and post your thought and suggest:yes
AMSWaves.

RizlaUK
10-10-2009, 06:22 AM
super work, i have not had time to test it yet, i'll send some arrays to API layer, i might be able to get shell file operation's working with this now.

johnraus
10-16-2009, 05:00 PM
As I can see all over, this memory plugin of yours , can do miracles :wow

Do you know of a place, beyond this forum, with samples about calling DLL's of of te windows API, or a good book to start with ?
(when I google I find a lot of C code samples, but this is beyond my understanding ...:eek:)

Scriptonite
10-17-2009, 12:08 AM
Wow, this is fantastic. Thanks for the plugin. :yes

RizlaUK
10-17-2009, 03:09 AM
@johnraus

most API code you will find will be C++ based, try searching VB6 examples as these also use lots of API

PureBasic has its own API layer which is how i learnt (what i know so far) of the windows API, MSDN is the best place to start

as for a good book, if you find one send me a link, lol

jassing
11-17-2009, 02:36 PM
I'm trying to use the plugin to call a dll that is expecting a structure by reference.. however, the result is that all elements are zero.

What am I doing wrong?

struct = Memory.CreateStructure("double, int, int, int, int, int, int, int, int, int, int, double, double, double") -- instead of "short, byte, string" we use "short, byte, int"
Dialog.Message("Test,Size", Memory.Size( struct ))

Application.SetLastError(0);

nDLL = DLL.CallFunction(_SystemFolder.."\\psapi.dll", "GetPerformanceInfo", struct..","..Memory.Size(struct), DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
Dialog.Message("Test, result", nDLL.."\r\n"..Application.GetLastError());

cData = ""
for x=1,14 do
cData = cData.."\r\n"..Memory.GetStructureData(struct, x, 0);
end
Dialog.Message('test, end', cData);

Memory.FreeStructure(struct) -- free all allocated memory of our structure

The 1st two dialogs make it look like it's going to work; but the final dialog showing the results is all zero's....

MicroByte
11-18-2009, 04:30 AM
remove the optional argument in the loop

for x=1,14 do
cData = cData.."\r\n"..Memory.GetStructureData(struct, x, 0);
end

AMSWaves
11-18-2009, 07:54 AM
I'm trying to use the plugin to call a dll that is expecting a structure by reference.. however, the result is that all elements are zero.

What am I doing wrong?

struct = Memory.CreateStructure("double, int, int, int, int, int, int, int, int, int, int, double, double, double") -- instead of "short, byte, string" we use "short, byte, int"
Dialog.Message("Test,Size", Memory.Size( struct ))

Application.SetLastError(0);

nDLL = DLL.CallFunction(_SystemFolder.."\\psapi.dll", "GetPerformanceInfo", struct..","..Memory.Size(struct), DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
Dialog.Message("Test, result", nDLL.."\r\n"..Application.GetLastError());

cData = ""
for x=1,14 do
cData = cData.."\r\n"..Memory.GetStructureData(struct, x, 0);
end
Dialog.Message('test, end', cData);

Memory.FreeStructure(struct) -- free all allocated memory of our structure

The 1st two dialogs make it look like it's going to work; but the final dialog showing the results is all zero's....

use this code :

struct = Memory.CreateStructure("int, int, int, int, int, int, int, int, int, int, int, int, int, int") -- instead of "short, byte, string" we use "short, byte, int"
Dialog.Message("Test,Size", Memory.Size( struct ))
Memory.SetStructureData(struct, 1, 0, Memory.Size(struct))

Application.SetLastError(0);

nDLL = DLL.CallFunction(_SystemFolder.."\\psapi.dll", "GetPerformanceInfo", struct..","..Memory.Size(struct), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
Dialog.Message("Test, result", nDLL.."\r\n"..Application.GetLastError());

cData = ""
for x=1,14 do
cData = cData.."\r\n"..Memory.GetStructureData(struct, x, 0);
end
Dialog.Message('test, end', cData);

Memory.FreeStructure(struct) -- free all allocated memory of our structure

jassing
11-18-2009, 09:18 AM
Thank you AMSWaves & MicroByte!

1) Wonderwhy the optional parameter makes a difference
2) Looks like Microbytes solution is the "proper" one; as the results look accurate. Need to investigate more.

Actually, neither appears to produce truely valid results... but this definately gives me something to go on..

Thank you.
-josh

jassing
11-18-2009, 10:02 AM
Well; I can't find it now; but I thought I had a reference to what types the memory plugin "knew" about...

Here's the WIP in case someone wants to take a stab at it -- the results should match (closely) with taskmanager's "performance" tab.

--[[
DWORD cb;
SIZE_T CommitTotal;
SIZE_T CommitLimit;
SIZE_T CommitPeak;
SIZE_T PhysicalTotal;
SIZE_T PhysicalAvailable;
SIZE_T SystemCache;
SIZE_T KernelTotal;
SIZE_T KernelPaged;
SIZE_T KernelNonpaged;
SIZE_T PageSize;
DWORD HandleCount;
DWORD ProcessCount;
DWORD ThreadCount;
--]]
tElements={"cb","CommitTotal","CommitLimit","CommitPeak","PhysicalTotal","PhysicalAvailable","SystemCache","KernelTotal","KernelPaged","KernelNonpaged","PageSize","HandleCount","ProcessCount","ThreadCount"};

--struct = Memory.CreateStructure("double, double, double, double, double, double, double, double, double, double, double, double, double, double")
--struct = Memory.CreateStructure("double, int, int, int, int, int, int, int, int, int, int, double, double, double")
struct = Memory.CreateStructure("int, int, int, int, int, int, int, int, int, int, int, int, int, int")
--struct = Memory.CreateStructure("dword, int, int, int, int, int, int, int, int, int, int, dword, dword, dword")

cSize = "Memory Size: "..Memory.Size( struct )
Memory.SetStructureData(struct, 1, 0, Memory.Size(struct))

Application.SetLastError(0);

nDLL = DLL.CallFunction(_SystemFolder.."\\psapi.dll", "GetPerformanceInfo", struct..","..Memory.Size(struct), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
cResult = "DLL Call Result: "..nDLL.." "..Application.GetLastError();

cData = ""
for x=1,14 do
cData = cData.."\r\n"..tElements[x].."="..Memory.GetStructureData(struct, x);
end
Memory.FreeStructure(struct) -- free all allocated memory of our structure

Dialog.Message("Results", cSize.."\r\n"..cResult.."\r\n".. cData);

MicroByte
11-18-2009, 01:56 PM
its returning the correct values, just in pages, use the "PageSize" eleament in conjunction with "KernelNonpaged, KernelPaged and KernelTotal" to get the size in bytes.

MicroByte
11-18-2009, 02:55 PM
but for the last hour iv been tiring to figure out how to go about it, with no success

jassing
11-18-2009, 09:09 PM
So, um, you go back on "it is returning the right value"?

yea; I can change int / double and get different results... none seem to fit it correctly...

Totally at a loss.
Thanks for trying tho.

reteset
11-19-2009, 01:32 PM
you need to use long instead of SIZE_T
and use a simple math Value*4

something like this

local ntmp = Memory.GetStructureData(struct, x, 0, "");
ntmp=ntmp*4;

i attached a full example

jassing
11-19-2009, 03:21 PM
AWESOME! Thank you VERY much.