Re: It works... now what?



#2pencil,

There is nothing really to optimise in what is high level code but you
can tidy it up a bit and remove a jump or two. There is no reason to
use a leading "@" in masm code for labels so I removed it.

Here is your algo tidied up a bit.

;
-------------------------------------------------------------------------

Proxy_Change PROC STDCALL,src:DWORD
; ------------------------------------
; this code opens the windows registry,
; replaces the proxy server address,
; & then sets enable to 0 or 1
; ------------------------------------

invoke RegOpenKey,HKEY_CURRENT_USER,ADDR lpSubKey,ADDR lpFullKey
cmp eax,ERROR_SUCCESS
je cont
invoke MessageBox,0,offset ErrMsg,offset AppName,MB_OK
ret

cont:
mov esi, src
cmp BYTE PTR [esi],48
je off

on:
mov arg,1
invoke RegSetValueEx,lpFullKey,addr lpValueName2,NULL,
00000004h,addr arg,4
invoke RegSetValueEx,lpFullKey,addr lpValueName,
NULL,00000001h,offset ProxyAddr,32
jmp done

off:
mov arg,0
invoke RegSetValueEx,lpFullKey,addr lpValueName2,NULL,
00000004h,addr arg,4
invoke RegSetValueEx,lpFullKey,addr lpValueName,
NULL,00000001h,offset FakeProxyAddr,32

done:
invoke RegCloseKey,lpFullKey
invoke MessageBox,0,addr Finish,offset AppName,MB_OK
ret

Proxy_Change ENDP

;
-------------------------------------------------------------------------

Regards,

hutch at movsd dot com

.



Relevant Pages

  • Get rid of window without the "staying in memory loop"
    ... invoke GetModuleHandle, NULL ... mov CommandLine,eax ... .if eax == FALSE ... NORM_IGNORECASE, addr pe32.szExeFile, -1, lpszExecutable, -1 ...
    (alt.lang.asm)
  • Re: Bugs in donkey.lib
    ... NULL,NULL,NULL,NULL, \ ADDR st_info, \ ... push eax ... invoke CloseHandle, ... MOV EAX,-1 however requires a test of EAX on exit as the flags are not set with a MOV, something that I found unacceptable and early on decided not to allow in functions that simply returned a state value. ...
    (alt.lang.asm)
  • Re: The revelation of St. f0dder the Divine
    ... mov eax, lpstruct ... lea edx, st_info ... invoke SetPriorityClass,pr_info.hProcess,priority ...
    (alt.lang.asm)
  • Re: MASM: Array Usage
    ... mov ah,green ... invoke GetModuleHandle,NULL ...
    (comp.lang.asm.x86)
  • Re: Array Usage
    ... invoke GetWindowRect,hDlg,addr rect ... ;save all the handles in an array for the hook ... mov ebp,addr hHandleArray ... inc ecx ...
    (comp.lang.asm.x86)