News:

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

Source code - Clear Projects VS

Started by RHL, March 03, 2012, 07:31:03 AM

Previous topic - Next topic

RHL

Hello all, As I wrote here is the code of my first application is a utility used to clean projects done in visual studio,
if you notice the weight of the folders reach even 70 MB! depends on the project, and this utility deletes files
we indicate that we want to delete.
also please ask if I can give advice seeing my code, thanks and I hope it is useful  :bg
also thankful that I had some doubts and helped me   :bg



dedndave


RHL

Quote from: dedndave on March 03, 2012, 01:25:42 PM
very nice   :U

thanks!
by the way, I tell them I wanted to debug the code but the stack with OllyDbg
the program was lost  :eek , and without debugger not know why the program works, maybe someone knows why

dedndave

ths might fix it
DlgProc USES EBX ESI EDI proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

other PROC's use registers, too
for example, GetNameProject uses EBX
but - as long as the DlgProc preserves and restores EBX, it should be OK
normally, we write the PROC's to preserve EBX, ESI, EDI, and EBP, if they are used, though
you could save ESI and EDI in the DlgProc and EBX if used in the other PROC's

in a call-back PROC (like DlgProc), you should preserve EBX, ESI, EDI, and EBP
and you should exit with the DF cleared if you set it
(the DF should also be cleared whenever an API function is called)
the assemblers' default prologue and epilogue take care of EBP for you
but - if you use EBP elsewhere without preserving it, you won't be able to access the DlgProc parms or locals   :P
GetNameProject uses EBP, but preserves it, as it should

RHL

oh thanks dedndave, just I realized just that by creating this project, I believed that the values ​​stored APIs registers used but it does not then know that I will have to modify registers in order to save memory? :/

dedndave

#5
Quotethen know that I will have to modify registers in order to save memory? :/

i don't understand the question - try to re-phrase it, please


looking through your code, i see some things that are a little off...

        cmp     eax,WM_COMMAND
        jne     win_msg2
        mov     edx,wParam
        ;// LOAD PROJECT? ///////////////////////////////////////
        cmp     edx,CMD_LOAD


when you receive a WM_COMMAND message from a control...
  wParam high word = Control-defined notification code
  wParam low word  = Control identifier
  lParam           = Handle to the control window


so, the code could be something like this...
        cmp     eax,WM_COMMAND
        jne     win_msg2
        movzx   edx,word ptr wParam    ;EDX = DX = control ID
        movzx   ecx,word ptr wParam+2  ;ECX = CX = notification code
        ;// LOAD PROJECT? ///////////////////////////////////////
        cmp     dx,CMD_LOAD


there are other places that test the values in EDX that could be updated, then

if you do as above, ECX and EDX will already be set up for you
checks_proc:
        ;// CLICKS CHECKS? /////////////////////////////////////
        movzx   eax,dx
        mov     ecx,edx
        shr     ecx,16
        cmp     ecx,BN_CLICKED
        jne     button_end
        push    eax
        call    pCheck
        jmp     end_if_


as for saving registers...
;#########################################################
;#########################################################
; mov edi,offset SLNVS
; mov esi,offset pathproject
; push edi
; push esi
        push    offset SLNVS
        push    offset pathproject
;#########################################################


and

;#########################################################
;#########################################################
; mov esi,offset heapAddExt
; mov edi,offset pathproject
; push esi
; push edi

        push    offset heapAddExt
        push    offset pathproject
;#########################################################


that way, DlgProc does not use ESI or EDI   :U

also, the "findfilestype" proc uses EBX and EDI and should preserve them
you can use PUSH/POP, or let the assembler do it for you...
findfilestype proc USES EBX EDI mypath:DWORD, lengthP:DWORD, lpftype:DWORD, lengthftype:DWORD

this code could be simplified a bit...
pCheck  proc

        push    edx
        mov     edx,[esp+08h]
        mov     eax,01h
        ;////////////////////////////////////////////////////////////////////
        ; if 0 = FALSE  else TRUE
        ;////////////////////////////////////////////////////////////////////
        cmp     edx,1050
        jne     check2
        not     [CHECKS]
        jmp     end_check
check2:
        cmp     edx,1051
        jne     check3
        not     [CHECKS+1]
        jmp     end_check
check3:
        cmp     edx,1052
        jne     check4
        not     [CHECKS+2]
        jmp     end_check
check4:
        cmp     edx,1053
        jne     check5
        not     [CHECKS+3]
        jmp     end_check
check5:
        cmp     edx,1054
        jne     check6
        not     [CHECKS+4]
        jmp     end_check
check6:
        cmp     edx,1055
        jne     check7
        not     [CHECKS+5]
        jmp     end_check
check7:
        cmp     edx,1056
        jne     check8
        not     [CHECKS+6]
        jmp     end_check
check8:
        cmp     edx,1057
        jne     check9
        not     [CHECKS+7]
        jmp     end_check
check9:
        cmp     edx,1058
        jne     check10
        not     [CHECKS+8]
        jmp     end_check
check10:
        cmp     edx,1059
        jne     check11
        not     [CHECKS+9]
        jmp     end_check
check11:
        cmp     edx,1060
        jne     check12
        not     [CHECKS+0ah]
        jmp     end_check
check12:
        cmp     edx,1061
        jne     check13
        not     [CHECKS+0bh]
        jmp     end_check
check13:
        cmp     edx,1062
        jne     check14
        not     [CHECKS+0ch]
        jmp     end_check
check14:
        cmp     edx,1063
        jne     no_found
        not     [CHECKS+0dh]
        jmp     end_check
no_found:
        mov     eax,0
end_check:
        pop     edx
        ret

pCheck endp



pCheck  proc

        push    edx
        mov     edx,[esp+08h]
        xor     eax,eax                ;EAX = 0

        ;////////////////////////////////////////////////////////////////////
        ; if 0 = FALSE  else TRUE
        ;////////////////////////////////////////////////////////////////////

        cmp     edx,1050
        jb      end_check

        cmp     edx,1063
        ja      end_check

        inc     eax                    ;EAX = 1
        not     CHECKS[edx-1050]

end_check:
        pop     edx
        ret

pCheck endp

:bg

this code doesn't really do anything that invoke won't do
KillFile proc
        push    edx
        mov     edx,[esp+08h]
        invoke  DeleteFile,edx
        pop     edx
        ret     04h
KillFile endp


just use
        invoke  DeleteFile,offset szFileName

RHL

great, thank you very much for u advice, buddy!  :green