Well I'm Back!
Took some time off programming to look at my linux pc and to do some networking!
I'm writing this simple little program which I have already written in C , the basis for it was strange... I remember my friends used to steal games from my computer so i made a launcher + keygen for all my important application. The keys generated for the games were generated in such a way that they would only work on my computer (or at the least a computer with the exact same environment variables and number of processors XD ). It worked by hiding the games old exe -> unhiding it -> launching it -> rehiding the exe.
Very basic I know but then again most of my friends still struggle with delphi <3
I was looking to do the same in assembly ( hence the unused extern _ShellExecuteA ) ; The program is working thusfar but at a certain point add esp , 16 ;; 12 extra bytes on the stack ?
there are three values on the stack which i swear I scraped .
Actually writing this gave me an idea of what's wrong but I'll post this anyway! ^^
BITS 32
extern _ExitProcess
extern _ReadFile
extern _OpenFile
extern _strcpy
extern _memcpy
extern _rename
extern _strstr
extern _ShellExecuteA
extern _puts
extern _GetLastError
global main
section .bss
Oldfile resb 255
Newfile resb 255
FileBuffer resb 500
section .data
Config db "Config.ini",0
NewLine db 0xa,0x0
FileHandle dd 0
section .text
main:
enter 136,0 ;allocates 136 bytes of space on the stack
push 0
lea ebx,[ebp-136]
push ebx
push Config
call _OpenFile
add esp , 136 ;frees 136 bytes of space on the stack
mov dword [FileHandle],eax
push 0
push 0
push 255
push FileBuffer
push dword [FileHandle]
call _ReadFile
add esp , 4 ;; For some reason the stack is four bits too big here
push NewLine ;; \n
push FileBuffer
call _strstr
add esp , 8
cmp eax , 0
JE lblExit
push eax ;; Save so i can set 0x0 and keep strstr value
sub eax,FileBuffer
dec eax
push eax
push FileBuffer
push Oldfile
call _memcpy
add esp , 12
pop eax ;; Get strstr answer and set byte to 0
mov byte [eax],0
inc eax
push eax
push Newfile
call _strcpy
add esp , 4
push Oldfile
push Newfile
call _rename
add esp , 4
;;Do Something with the renamed file
push Newfile
push Oldfile
call _rename
add esp , 16 ;; 12 extra bytes on the stack ?
lblExit:
push 0
call _ExitProcess
;;NOTES:
;;OFSTRUCT is 136 bytes large