View previous topic :: View next topic |
Author |
Message |
GregLand Valued Contributor
Joined: 15 Jun 2004 Posts: 212 Location: FRANCE
|
Posted: Wed Nov 28, 2007 3:45 am Post subject: |
|
|
For the path of app i can do like that :
Code: | # Get the path of runing app
list create,1
list modules,1,app.exe
%%app_path = @item(1,0)
list close,1
|
But I don't know how to find the Handle using GetModuleHandleA or GetModuleHandleW
Code: | # Get the Handle
loadlib "kernel32.dll"
%t = @lib("kernel32.dll","GetModuleHandleA",INT:,NIL:%%app_path)
freelib "kernel32.dll"
|
I don't know how to use this (if it's right)
Can you help me ? |
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed Nov 28, 2007 8:59 pm Post subject: |
|
|
GregLand wrote: | For the path of app i can do like that :
Code: | # Get the path of runing app
list create,1
list modules,1,app.exe
%%app_path = @item(1,0)
list close,1
|
But I don't know how to find the Handle using GetModuleHandleA or GetModuleHandleW
Code: | # Get the Handle
loadlib "kernel32.dll"
%t = @lib("kernel32.dll","GetModuleHandleA",INT:,NIL:%%app_path)
freelib "kernel32.dll"
|
I don't know how to use this (if it's right)
Can you help me ? |
Code: | # Get the Handle
loadlib kernel32.dll
%t = @lib(kernel32,GetModuleHandleA,INT:,NIL:)
freelib kernel32
|
If module name is NULL (ie.. NIL: ), GetModuleHandle returns a handle of the file used to create the calling process (e.g. ... the Exe that calls GetModuleHandle). _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
GregLand Valued Contributor
Joined: 15 Jun 2004 Posts: 212 Location: FRANCE
|
Posted: Wed Nov 28, 2007 9:12 pm Post subject: |
|
|
Ok thanks for your help !
Can you tell me how can I "join" this 3 script to reduce the memory of the runing process App.exe?
Code: | # Get the path of runing app
%%app = App.exe
list create,1
list modules,1,%%app
%%app_path = @item(1,0)
list close,1 |
Code: | # Get the Handle
loadlib kernel32.dll
%t = @lib(kernel32,GetModuleHandleA,INT:,NIL:)
freelib kernel32 |
Code: | #Reduce memory
loadlib "psapi.dll"
%t = @lib("psapi.dll","EmptyWorkingSet",INT:,%%handle)
freelib "psapi.dll" |
Last edited by GregLand on Thu Nov 29, 2007 12:42 am; edited 2 times in total |
|
Back to top |
|
|
ShinobiSoft Professional Member
Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Wed Nov 28, 2007 11:59 pm Post subject: |
|
|
dragonsphere wrote: |
If module name is NULL (ie.. NIL: ), GetModuleHandle returns a handle of
the file used to create the calling process (e.g. ... the Exe that calls
GetModuleHandle). |
Johnny,
I think GregLand is actually wanting the HINSTANCE of a non VDS app. At
least that's what I understood from his first post in this thread, that's why
me previous post was answered the way that it was, though I prolly
should've included sample code. _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Thu Nov 29, 2007 9:37 pm Post subject: |
|
|
GregLand wrote: | Ok thanks for your help !
Can you tell me how can I "join" this 3 script to reduce the memory of the runing process App.exe?
Code: | # Get the path of runing app
%%app = App.exe
list create,1
list modules,1,%%app
%%app_path = @item(1,0)
list close,1 |
Code: | # Get the Handle
loadlib kernel32.dll
%t = @lib(kernel32,GetModuleHandleA,INT:,NIL:)
freelib kernel32 |
Code: | #Reduce memory
loadlib "psapi.dll"
%t = @lib("psapi.dll","EmptyWorkingSet",INT:,%%handle)
freelib "psapi.dll" |
|
Code: |
# Get the path of runing app
%%app = App.exe
list create,1
list modules,1,%%app
%%app_path = @item(1,0)
list close,1
# Get the Handle
loadlib kernel32.dll
%%handle = @lib(kernel32,GetModuleHandleA,INT:,STR:%%app_path)
freelib kernel32
#Reduce memory
loadlib psapi.dll
%t = @lib(psapi,EmptyWorkingSet,INT:,INT:%%handle)
freelib psapi
|
_________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Thu Nov 29, 2007 9:45 pm Post subject: |
|
|
Unless your program launches that program you will not be able to change it's working set size. _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
GregLand Valued Contributor
Joined: 15 Jun 2004 Posts: 212 Location: FRANCE
|
Posted: Fri Nov 30, 2007 3:06 am Post subject: |
|
|
dragonsphere wrote: | Unless your program launches that program you will not be able to change it's working set size. |
Thanks for the script... but it doesn't look to work correctly...
%%handle and %t return 0 (while the app %%app is running)
Code: |
# run the app
run "D:\programmes\FireFox\firefox.exe" -Profile "D:\programmes\FireFox\profil"
# Get the path of runing app
%%app = firefox.exe
list create,1
list modules,1,%%app
%%app_path = @item(1,0)
list close,1
# Get the Handle
loadlib kernel32.dll
%%handle = @lib(kernel32,GetModuleHandleA,INT:,STR:%%app_path)
freelib kernel32
#Reduce memory
loadlib psapi.dll
%t = @lib(psapi,EmptyWorkingSet,INT:,INT:%%handle)
freelib psapi
|
|
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri Nov 30, 2007 4:54 pm Post subject: |
|
|
Gregland,
It is not going to work. The Exe that you are trying to reduce the memory usage has to be mapped to the same memory as the Exe that is calling these functions. This is not really possible. These functions are meant to be used inside a Exe or DLL to control memory usage of the Exe calling the functions. It is usually not allowed for an external Exe to control the memory of another Exe in the Windows memory model. If you were allowed to do that then you could really do some damage. Personally I would contact the developer of the Exe that you are trying to do this with and ask them to optimize their memory usage. _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
GregLand Valued Contributor
Joined: 15 Jun 2004 Posts: 212 Location: FRANCE
|
Posted: Fri Nov 30, 2007 5:12 pm Post subject: |
|
|
Ok... thanks for your help...
Not very important |
|
Back to top |
|
|
|
|
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
|
|