unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Programming > Assembly

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 03-20-2010, 08:52 PM
learn_more learn_more is offline
Member
 
Join Date: Feb 2010
Posts: 59
Default URLEncode

by Max_Power

Encodes a URL so that a browser can handle it. For example if you give the url http://www.x.com/file.php?string=this is a fracking test [dood] it would return http://www.x.com/file.php?string=thi...est+%5Bdood%5D.

This is useful if you are doing stuff with google, doing CGI in MASM, or many other things.

Code:
	Encode_URL PROTO :DWORD,:DWORD
	
	.data
		szAllowed db "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:/.?=_-$(){}~&",0
		szHexFormat db "%X",0
	
	.code
	
	Encode_URL proc USES ecx edi esi lpSource:DWORD,lpDestination:DWORD
		LOCAL szCurChar[2]:BYTE
		LOCAL szCharCode[5]:BYTE
		LOCAL dwLen:DWORD
		
		invoke lstrlen,lpSource
		mov dwLen,eax
		
		xor ecx,ecx	;Offset in source string
		xor edx,edx ;Offset is destination string
		
		.REPEAT
			;Get the current character
			mov edi,lpSource
			mov al,[edi+ecx]
			lea edi,szCurChar
			mov [edi],al
			mov al,0
			mov [edi+1],al
	
			;Check if the character is allowed
			push ecx
			push edx
			invoke InString,1,ADDR szAllowed,ADDR szCurChar
			pop edx
			pop ecx
			
			mov edi,lpDestination
			.IF eax<1
				;Check if it is a space, if so replace it with
				;a plus sign otherwise replace it with %hex val
				mov al,szCurChar
				.IF al==20h
					mov al,'+'
					mov [edi+edx],al
				.ELSE
					mov al,'%'
					mov [edi+edx],al
					
					;Convert the character code for the illegal
					;char to a string
					xor eax,eax
					mov al,szCurChar
					push ecx
					push edx
					invoke wsprintf,ADDR szCharCode,ADDR szHexFormat,eax
					pop edx
					pop ecx
					
					inc edx
					lea esi,szCharCode
					mov eax,[esi]
					mov [edi+edx],eax
					mov eax,[esi+1]
					inc edx
					mov [edi+edx],eax
				.ENDIF
			.ELSE
				mov al,szCurChar
				mov [edi+edx],al
			.ENDIF

			inc ecx
			inc edx
		.UNTIL ecx==dwLen
		
		ret
	Encode_URL endp

Last edited by learn_more; 03-20-2010 at 09:12 PM.
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
urlencode

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 06:18 AM.