forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Write Process Memory

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 763
Location: Eastman, GA

PostPosted: Mon Mar 17, 2014 7:20 pm    Post subject: Write Process Memory Reply with quote

Confused

Normally I struggle through stuff before I ask, but this time I'm making an exception!

Anyone ever use WriteProcessMemory or have a good clue how to do so?

http://msdn.microsoft.com/en-us/library/windows/desktop/ms681674(v=vs.85).aspx

I need to write values to cityofheroes.exe which I now use as a miniature set since they shut down the server.

Memory address 01671544 is of primary concern.

Any help appreciated, I'll let you know if I crank it out beforehand!

Starts with info from this post...
http://www.vdsworld.com/forum/viewtopic.php?t=4911&highlight=memory
Back to top
View user's profile Send private message AIM Address
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 763
Location: Eastman, GA

PostPosted: Mon Mar 17, 2014 9:58 pm    Post subject: Reply with quote

FAIL! Even switched to reading memory, thought it would be easier.

Code:

#DEFINE COMMAND,REDUCEMEMORY

# create a list to hold the names and process ids of all
# running programs
list create,1
%%ProcessId_Lst = 1
List TaskList,%%ProcessId_Lst,NI
# locate the vds.exe program
%A = @match(%%ProcessId_Lst,cityofheroes.exe)
If %A
  # extract the process id
  PARSE "%%name;%%id",@Item(%%ProcessId_Lst)
   # reduce the memory footprint of the exe.
  ReduceMemory %%id
Else
  Info could not find vds.exe
End
stop
:ReduceMemory
  # This subroutine will reduce the memory footprint
   # of the current exe or of the specified process ID
  loadlib kernel32.dll
  If %1
     # Get a handle to the specified process
    %h = @lib(kernel32,OpenProcess,INT:,INT:$1F0FFF,INT:0,INT:%1)
    info %h
%S = @FILL(255)
info @len(%S)
%L = @BINARY(LARGEINT,@LEN(%S))
      If @unequal(%h,0)
        # reduce its current memory
            %i = @lib(kernel32,ReadProcessMemory,INT:,%h,NIL:,$01671544,INT:,@addr("%S"),@addr("%L"))
            if %i
            info %i

            end
               # close the handle
      %h = @lib(kernel32,CloseHandle,BOOL:,INT:%h)
    End
  Else
     # reduce the memory usage of the current process
    #%t = @lib(psapi,EmptyWorkingSet,INT:,INT:-1)
  End
  freelib kernel32
              info @adjust(%S)
exit

Back to top
View user's profile Send private message AIM Address
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 763
Location: Eastman, GA

PostPosted: Tue Mar 18, 2014 6:08 pm    Post subject: BUMP Reply with quote

Could use help on this, otherwise I (may) have to rewrite a fairly large project in Visual Basic, which is second rate in my book ;(

I was able to write a Visual Basic DLL that does this, but for some reason it doesn't hook into a VDS executable properly. Only other VB executable will call it properly I think.

Now I do plan on writing some pretty cool DLL's for VDS in VB, but my VDSMemAddr.dll has bombed.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group