News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Preventing Your Disk Small

Started by six_L, February 10, 2005, 02:03:30 PM

Previous topic - Next topic

six_L

hello, all
here a code written by Flasher (Russian). it can clean Temporary InternetFile and Recycle. very usefully!


;@echo off
;goto make
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.586                      ; create 32 bit code
.model flat, stdcall      ; 32 bit memory model
option casemap :none      ; case sensitive
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\shell32.inc
include \masm32\include\wininet.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\wininet.lib

include \masm32\macros\macros.asm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.CODE
CleanTemporaryInternetFiles proc
local hCache:HANDLE
local dwBufferSize:DWORD
local hHeap:HANDLE
local pHeap:LPVOID
local CacheEntry[16]:INTERNET_CACHE_ENTRY_INFO
and hCache,0
and pHeap,0
mov dwBufferSize,sizeof CacheEntry
invoke FindFirstUrlCacheEntry,0,addr CacheEntry,addr dwBufferSize
.if eax != 0
mov hCache,eax
.else
invoke GetLastError
.if eax == ERROR_INSUFFICIENT_BUFFER
invoke GetProcessHeap
mov hHeap,eax
invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,dwBufferSize
mov pHeap,eax
invoke FindFirstUrlCacheEntry,0,addr CacheEntry,addr dwBufferSize
.if eax != 0
mov hCache,eax
.endif
.endif
.endif
.if hCache != 0
.while TRUE
invoke FindNextUrlCacheEntry,hCache,addr CacheEntry,addr dwBufferSize
.if eax == FALSE
invoke GetLastError
.break .if eax == ERROR_NO_MORE_ITEMS
.endif
invoke DeleteUrlCacheEntry,CacheEntry.lpszSourceUrlName
.endw
invoke FindCloseUrlCache,hCache
.endif
.if pHeap != 0
invoke HeapFree,hHeap,0,pHeap
.endif
ret
CleanTemporaryInternetFiles endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CleanRecycle proc
       invoke SHAddToRecentDocs,SHARD_PATH,0
       invoke SHEmptyRecycleBin,NULL,NULL,SHERB_NOCONFIRMATION+SHERB_NOPROGRESSUI+SHERB_NOSOUND
       ret
CleanRecycle endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke MessageBox,NULL,chr$("Did You Really Cleaning Temporary InternetFile ?"),chr$("Preventing Your Disk Small v1.01"),MB_YESNO or MB_ICONASTERISK
.if eax==IDYES
invoke CleanTemporaryInternetFiles
        invoke MessageBox,NULL,chr$("Finished"),chr$("OK"),MB_OK or MB_ICONINFORMATION
.endif
invoke MessageBox,NULL,chr$("Did You Really Cleaning Recycle ?"),chr$("Preventing Your Disk Small v1.01"),MB_YESNO or MB_ICONASTERISK
.if eax==IDYES
invoke CleanRecycle
        invoke MessageBox,NULL,chr$("Finished"),chr$("OK"),MB_OK or MB_ICONINFORMATION
.endif
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

end start

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
:make
set name=clean_1

    \masm32\bin\ml /c /coff %name%.bat
    \masm32\bin\Link /subsystem:windows %name%.obj
   
    if exist *.bak del *.bak
    if exist *.obj del *.obj
    echo.

regards

pbrennick

The Recycle Bin cleanup part of the program works quite nicely but the rest doesn't work on my machine at all.  It just hogs the processor and never deletes anything.  I let it hog cpu time for over 40 minutes and looked into the area where the files should be deleted from and they were all still there.  I had to force it to quit.

Paul

six_L

hello, pbrennick
Thanks for you are interestting it.
in my PC(windows xp home edition sp2), It works fine.
it del the files in c:\Documents and Settings\[log userName]\Local Settings\Temporary Internet Files\
regards

pbrennick

#3
Yeah, that is where I was watching.  I will try again but the last try didn't selete anything from that location. Actually,c:\Documents and Settings\[log userName]\Local Settings\Temporary Internet Files\Content.IE5\ contains the uniquely named directories with the internet files.

Paul

six_L

hi, pbrennick
I'm glad to see your msg.
here is the clean_2.bat. it may be given you some error msg.

;@echo off
;goto make
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.586                      ; create 32 bit code
.model flat, stdcall      ; 32 bit memory model
option casemap :none      ; case sensitive
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\shell32.inc
include \masm32\include\wininet.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\wininet.lib

include \masm32\macros\macros.asm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.CODE
CleanTemporaryInternetFiles proc

local hCache:HANDLE
local dwBufferSize:DWORD
local hHeap:HANDLE
local pHeap:LPVOID
local CacheEntry[16]:INTERNET_CACHE_ENTRY_INFO

and hCache, NULL
and pHeap, NULL
mov dwBufferSize, sizeof CacheEntry
invoke FindFirstUrlCacheEntry, NULL, addr CacheEntry, addr dwBufferSize
.if eax != NULL
mov hCache, eax
.else
invoke GetLastError
.if eax == ERROR_INSUFFICIENT_BUFFER
invoke GetProcessHeap
mov hHeap, eax
invoke HeapAlloc, hHeap, HEAP_ZERO_MEMORY, dwBufferSize
mov pHeap, eax
; Try again with appropriate buffer size
invoke FindFirstUrlCacheEntry, NULL, addr CacheEntry, addr dwBufferSize
.if eax != NULL
mov hCache, eax
.else
invoke GetLastError
.if eax == ERROR_INSUFFICIENT_BUFFER
invoke MessageBox, NULL, chr$("Can't allocatebuffer of appropriate size."),chr$("Preventing Your Disk Small v1.01"), MB_ICONERROR
.else
invoke MessageBox, NULL, chr$("Fail to clear."), chr$("Preventing Your Disk Small v1.01"), MB_ICONERROR
.endif
.endif
.endif
.endif

.if hCache != NULL
.while TRUE
invoke FindNextUrlCacheEntry, hCache, addr CacheEntry, addr dwBufferSize
.if eax == FALSE
invoke GetLastError
.break .if eax == ERROR_NO_MORE_ITEMS
.endif
invoke DeleteUrlCacheEntry, CacheEntry.lpszSourceUrlName
.endw
invoke FindCloseUrlCache, hCache
.endif

.if pHeap != NULL
invoke HeapFree, hHeap, 0, pHeap
.endif
ret

CleanTemporaryInternetFiles endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CleanRecycle proc
       invoke SHAddToRecentDocs,SHARD_PATH,0
       invoke SHEmptyRecycleBin,NULL,NULL,SHERB_NOCONFIRMATION+SHERB_NOPROGRESSUI+SHERB_NOSOUND
       ret
CleanRecycle endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke MessageBox,NULL,chr$("Did You Really Cleaning Temporary InternetFile ?"),chr$("Preventing Your Disk Small v1.01"),MB_YESNO or MB_ICONASTERISK
.if eax==IDYES
invoke CleanTemporaryInternetFiles
        invoke MessageBox,NULL,chr$("Finished"),chr$("OK"),MB_OK or MB_ICONINFORMATION
.endif
invoke MessageBox,NULL,chr$("Did You Really Cleaning Recycle ?"),chr$("Preventing Your Disk Small v1.01"),MB_YESNO or MB_ICONASTERISK
.if eax==IDYES
invoke CleanRecycle
        invoke MessageBox,NULL,chr$("Finished"),chr$("OK"),MB_OK or MB_ICONINFORMATION
.endif
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

end start

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
:make
set name=clean_2

    \masm32\bin\ml /c /coff %name%.bat
    \masm32\bin\Link /subsystem:windows %name%.obj
   
    if exist *.bak del *.bak
    if exist *.obj del *.obj
    echo.



when i'm exploring on internet about 4 hours, My PC created 26M files in  c:\Documents and Settings\[log userName]\Local Settings\Temporary Internet Files\ . if i del those with handcraft. may be slowly. it helps me a lot.

login as a administrator.I tested clean_1.exe on 

  • Microsoft Windows XP Professional version 2002 Service Pack 2
  • Microsoft Windows XP Home Edition version 2002 Service Pack 2
no any problems.

I actually don't know It can't work on your PC

have a nice day.
regards

pbrennick

After some clean up manually in that area, it now deletes the files but the process never terminates.  If I force it down and then rerun it, it reports a failure and then terminates even though there is nothing to delete.  I am done with this.

Paul

six_L

Hi, paul
the problem that you said is been appeared in my PC, i modified
[local CacheEntry[16]:INTERNET_CACHE_ENTRY_INFO] ==>[local CacheEntry[64]:INTERNET_CACHE_ENTRY_INFO]
it worked until now.

Thanks.

regards

pbrennick

Thank you for the update.  At some point I probably would have tried a few things myself, but been very busy, lately.  I am glad you were able to duplicate the problem and I thank you for a working solution.  It does a fairly good job, good enough for me anyhow.

Thank you,
Paul

GERMANY


;~~~~~~~~~~~~~~~hi from GERMANY~~~~~~~~~~~~~~
;~~~~~~~~~~~~clean your cache girl~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~and enjoy!~~~~~~~~~~~~~~~~
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\wininet.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\wininet.lib
CTEXT MACRO text:VARARG
local TxtName
.data
TxtName BYTE text,0
.code
EXITM <ADDR TxtName>
ENDM
.code
CleanCacheEntry proc pEntryType: DWORD
local hCache:HANDLE
local dwBufferSize:DWORD
local dwBufferSizeSaved:DWORD
local hHeap:HANDLE
local pHeap:LPVOID
local CacheEntry[16]:INTERNET_CACHE_ENTRY_INFO
and hCache,0
and pHeap,0
mov dwBufferSize,sizeof CacheEntry
invoke GetProcessHeap
mov hHeap,eax
i_set_my_buffer:
lea esi,dwBufferSize
lea edi,dwBufferSizeSaved
movsd
invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,dwBufferSize
mov pHeap,eax
i_find_first_entry:
invoke FindFirstUrlCacheEntry,pEntryType,pHeap,addr dwBufferSize
mov hCache,eax
test eax,eax
jne i_remove_entry
invoke GetLastError
cmp eax,ERROR_INSUFFICIENT_BUFFER
jne i_remove_my_buffer
invoke HeapFree,hHeap,0,pHeap
jmp i_set_my_buffer
i_remove_entry:
mov esi,pHeap
add esi,[esi]
invoke DeleteUrlCacheEntry,esi
lea esi,dwBufferSizeSaved
lea edi,dwBufferSize
movsd
i_find_next_entry:
        invoke FindNextUrlCacheEntry,hCache,pHeap,addr dwBufferSize
test eax,eax
jne i_remove_entry
invoke GetLastError
cmp eax,ERROR_INSUFFICIENT_BUFFER
jne i_remove_my_buffer
i_enlarge_my_buffer:
lea esi,dwBufferSize
lea edi,dwBufferSizeSaved
movsd
invoke HeapFree,hHeap,0,pHeap
invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,dwBufferSize
mov pHeap,eax
jmp i_find_next_entry
i_remove_my_buffer:
invoke FindCloseUrlCache,hCache
invoke HeapFree,hHeap,0,pHeap
ret
CleanCacheEntry endp
start:
invoke CleanCacheEntry,CTEXT("visited:") ; clean history
invoke CleanCacheEntry,CTEXT("cookie:")       ; clean cookies
invoke CleanCacheEntry,0                      ; clean the rest (Temporary Internet Files)
invoke ExitProcess,0
end start