AutoHotkey Community

It is currently May 27th, 2012, 1:15 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: January 10th, 2010, 1:47 pm 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
CacheSet - A Microsoft sysinterals tool.

I would like to be able to replicate this programs functionality in AHK. I already have a working script with a nice GUI that replicates the API call from empty.exe and I would like to add the ability to reset/clear the system cache.

I think these two API's will be involved (moreso the second one)
GetSystemFileCacheSize API
SetSystemFileCacheSize API

For reference, HERE is the EmptyWorkingSet function that some users were very kind to assist me with.

The inspiration for this tool comes from CleanMem which is a really neat tool, but has zero user interface and relies on the task scheduler to function on a schedule.

Once this tool is done I have every intention of posting it in the Scripts section of our forum with source code so that other may use it as well, but my personal reasons for writing this are for use on some of our SQL servers at work that are struggling under their current load.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 13th, 2010, 6:21 am 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
bump? Anyone? You would very likely be ensuring I get a raise\promotion when my yearly review comes up if I can make this tool work =D haha


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 20th, 2010, 8:20 am 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
I posted the script im working on here in hopes that it will spur some interest and maybe I can get some help in implementing this feature :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 12:13 pm 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
Heres my attempt, which fails. Hopefully this will give someone an idea for what I am trying to accomplish here and they will be able to give me some pointers.
Code:
p := ClearCache()
If not p
   MsgBox, Success
If p
   MsgBox, Fail`n%p%

ClearCache()
{
   k := DllCall("ntdll.dll\NtSetSystemInformation", "Str", SYSTEM_CACHE_INFORMATION, "UInt", -1, "UInt", -1)
   If not k
      k := DllCall("Kernel32.dll\GetLastError")
   Return k
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 12:24 pm 
Offline

Joined: February 7th, 2008, 9:48 pm
Posts: 509
When i saw your first post i wondered why are you not interacting with the sysinternals program.Like reading the editwindows and activating the buttons?

You can hide the sysinternal window if necessary.

I guess you need to have the knowledge of the sysinternal team to go so deep into the workings of windows.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 12:28 pm 
What do you expect a return value from first dll call? May be it is success and the last error call do let a false value return for whole function. I recommend first to save the last error in ErrorLevel. And prior to second call check the first errorlevel.

I cant do this now.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 1:10 pm 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
Tuncay n-l-i mobile wrote:
What do you expect a return value from first dll call? May be it is success and the last error call do let a false value return for whole function. I recommend first to save the last error in ErrorLevel. And prior to second call check the first errorlevel.

I cant do this now.


I was simply using it as a debug tool while I was making the DllCall, for my actual script I wouldnt need that. I just want to be able to flush the system file cache on demand.

yume wrote:
When i saw your first post i wondered why are you not interacting with the sysinternals program.Like reading the editwindows and activating the buttons?

You can hide the sysinternal window if necessary.

I guess you need to have the knowledge of the sysinternal team to go so deep into the workings of windows.


Im working with the actual Windows API's because I would like to incorporate the API call into another script I wrote HERE


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2010, 1:51 pm 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
So Ive found out I need to enable the SE_INCREASE_QUOTA privelege. Im sure this requires some abiity to use DllCalls. Anyone have any good examples I could look at?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2010, 3:20 pm 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
Bumping this. I would still love some help to get this working. Ive got the source code for CacheSet but my understanding of the C language is pretty poor.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2010, 6:20 pm 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
strictlyfocused02 wrote:
Heres my attempt, which fails. Hopefully this will give someone an idea for what I am trying to accomplish here and they will be able to give me some pointers.
Code:
p := ClearCache()
If not p
   MsgBox, Success
If p
   MsgBox, Fail`n%p%

ClearCache()
{
   k := DllCall("ntdll.dll\NtSetSystemInformation", "Str", SYSTEM_CACHE_INFORMATION, "UInt", -1, "UInt", -1)
   If not k
      k := DllCall("Kernel32.dll\GetLastError")
   Return k
}


Using this I get a return value of -2147483646 which I cannot interpet to save my life. It does not seem like a valid last error code.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 9th, 2010, 3:10 pm 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
bumping my strange function help request for an undocumented API call :lol:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 11th, 2010, 2:31 am 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
GetLastError Function @ msdn wrote:
If the function is not documented to set the last-error code, the value returned by this function is simply the most recent last-error code to have been set; some functions set the last-error code to 0 on success and others do not

In more than one place on web i have found that the "prototype" of NtSetSystemInformation() is

Quote:
NtSetSystemInformation (IN SYSTEMINFOCLASS SystemInformationClass,
IN PVOID SystemInformation,
IN DWORD SystemInformationLength);

(ie no "OUT"/return parameter)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 14th, 2010, 7:27 pm 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
Mouser over at DonationCoders was kind enough to help me out to get this far, but our collective knowledge wasnt qutie enough to finish the function. Heres where Im at:
Code:
p := ClearCache()

ClearCache()
{
   VarSetCapacity(Var, 36)
   NumPut(-1, Var, 12, "ULong")
   NumPut(-1, Var, 16, "ULong")
   DllCall("ntdll.dll\NtSetSystemInformation", "UInt", 0x15, "UInt", &Var, "UInt", 36)
   Return
}


Anyone able to point me in the right direction?

Edit - BTW, mouser found and shared THIS with me showing the structure for what were working with here


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2010, 5:18 pm 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
strictlyfocused02 wrote:
Mouser over at DonationCoders was kind enough to help me out to get this far, but our collective knowledge wasnt qutie enough to finish the function. Heres where Im at:
Code:
p := ClearCache()

ClearCache()
{
   VarSetCapacity(Var, 36)
   NumPut(-1, Var, 12, "ULong")
   NumPut(-1, Var, 16, "ULong")
   DllCall("ntdll.dll\NtSetSystemInformation", "UInt", 0x15, "UInt", &Var, "UInt", 36)
   Return
}


Anyone able to point me in the right direction?

Edit - BTW, mouser found and shared THIS with me showing the structure for what were working with here


Anyone? Anything at all? Ive been working on this on and off since Jan ...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 4th, 2010, 3:19 am 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
bumping again :(


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], Leef_me, Ohnitiel and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group