sysutils.inc

来自「The final version of UPX scrambler and P」· INC 代码 · 共 89 行

INC
89
字号

; System functions

proc GetMainArgs
     local flag:BYTE
     ;--------------
     push ebx edi esi
     invoke GetCommandLineA
     mov edi,eax
     invoke lstrlenA,eax
     mov esi,eax
     invoke VirtualAlloc,0,esi,MEM_COMMIT,PAGE_READWRITE
     test eax,eax
     jz @@ret
     mov ebx,eax
     xor ecx,ecx
     mov [flag],0
     mov [_argc],0
     mov [_argv],ebx
     .while ecx < esi
	    .if byte [edi+ecx] <> 22h
		.if byte [edi+ecx] <> 20h
@@:		    mov al,[edi+ecx]
		    mov [ebx],al
		    inc ebx
		.else
		    cmp [flag],0
		    jne @r
		    inc ebx
		    .if byte [edi+ecx+1] <> 20h
			inc [_argc]
			.if [_argc] > MAX_PARAM_COUNT
			    mov [_argc],MAX_PARAM_COUNT
			    jmp @@ret
			.endif
			mov eax,[_argc]
			shl eax,2
			mov [_argv+eax],ebx
		    .endif
		.endif
	    .else
		not [flag]
	    .endif
	    inc ecx
     .endw
@@ret:
     pop esi edi ebx
     ret
endp

proc ParamStr,nIndex:BYTE;:LPCTSTR ; -> EAX: pointer to n-param
     mov edx,[_argc]
     .if [nIndex] < dl
	 movzx edx,[nIndex]
     .endif
     shl edx,2
     mov eax,[_argv+edx]
     ret
endp

proc Randomize
     local SystemTime:SYSTEMTIME
     ;--------------------------
     lea eax,[SystemTime]
     invoke GetSystemTime,eax
     movzx eax,[SystemTime.wHour]
     imul eax,60
     add ax,[SystemTime.wMinute]
     imul eax,60
     xor edx,edx
     mov dx,[SystemTime.wSecond]
     add eax,edx
     imul eax,1000
     mov dx,[SystemTime.wMilliseconds]
     add eax,edx
     mov [RandSeed],eax
     ret
endp

proc Random,dwRange:DWORD ; -> EAX: random number
     mov eax,[dwRange]
     imul edx,[RandSeed],08088405h
     inc edx
     mov [RandSeed],edx
     mul edx
     mov eax,edx
     ret
endp

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?