Old 6th December 2011, 17:12   #1
aerDNA
Senior Member
 
aerDNA's Avatar
 
Join Date: Feb 2007
Location: Rijeka, Croatia
Posts: 225
System: create structure in preallocated memory?

I know how to create structures with System plugin but how do I create one at a given memory address?

PostEnd:
aerDNA is offline   Reply With Quote
Old 6th December 2011, 18:12   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
The usage example for System::Copy at the top of the plug-in readme shows how to do it.

Stu
Afrow UK is offline   Reply With Quote
Old 6th December 2011, 18:16   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,263
System::Call '*$0(i 666,i 1337)' in the memory starting at $0 (The set struct members syntax)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 6th December 2011, 18:51   #4
aerDNA
Senior Member
 
aerDNA's Avatar
 
Join Date: Feb 2007
Location: Rijeka, Croatia
Posts: 225
I studied that part in System readme before posting but I must be getting something wrong. What I need is to create a blank POINT structure in another process' memory and pass the pointer with SendMessage. Is System::Call "*$0(&i4, &i4)" ok, $0 being an existing address?

PostEnd:
aerDNA is offline   Reply With Quote
Old 6th December 2011, 19:42   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,263
To write to the memory in another process you would first create the struct locally inside the nsis process normally with system and then you would have to call OpenProcess, VirtualAllocEx and WriteProcessMemory (This is not going to be pretty, and it sounds like you are doing something hacky)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 6th December 2011, 20:11   #6
aerDNA
Senior Member
 
aerDNA's Avatar
 
Join Date: Feb 2007
Location: Rijeka, Croatia
Posts: 225
I'm not a coder so pretty much everything's hacky to me but what i'm trying do is save/restore desktop icons layout. Found the code in Delphi, now I'm trying to port it to nsis. I already did the OpenProcess & VirtualAllocEx part but "first create the struct locally" is the thing I needed to hear. Thanks for pointing me in the right direction, I'll let you know if I was successful, or stuck again.

PostEnd:
aerDNA is offline   Reply With Quote
Old 6th December 2011, 22:28   #7
aerDNA
Senior Member
 
aerDNA's Avatar
 
Join Date: Feb 2007
Location: Rijeka, Croatia
Posts: 225
Woohoo! Did it. My main problem was failing to understand that System can't directly manage the memory of another process. It probably goes without saying for someone with proper knowledge but I'm just learning as I go along. Still got scripting ahead of me to achieve what I want but the bricks are here, all I got to do now is build. Thanks again, Anders.

PostEnd:
aerDNA is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump