News:

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

Type: PCTSTR & PTSTR

Started by bomz, April 19, 2011, 12:23:58 PM

Previous topic - Next topic

bomz

http://msdn.microsoft.com/en-us/library/bb773774%28v=VS.85%29.aspx     
Quote
pszURL [in]
    Type: PCTSTR
    A null-terminated string of maximum length INTERNET_MAX_URL_LENGTH that contains a full or partial URL, as appropriate for the value in dwFlags.
pszEscaped [out]
    Type: PTSTR
    The buffer that receives the converted string, with the unsafe characters converted to their escape sequences.

Quote
.386

.model flat, stdcall
option casemap :none

include \MASM32\INCLUDE\windows.inc
include \MASM32\INCLUDE\user32.inc
includelib \MASM32\LIB\user32.lib
include \MASM32\INCLUDE\kernel32.inc
includelib \MASM32\LIB\kernel32.lib
include \MASM32\INCLUDE\shlwapi.inc
includelib \MASM32\LIB\shlwapi.lib

.data
mestitle    db " URL Convert ",0
Url      db "http://mirror.yandex.ru/mozilla/firefox/releases/latest-4.0/win32/ru/Firefox%20Setup%204.0.exe",0

.data?
String db INTERNET_MAX_URL_LENGTH dup (?)

.code
start:

invoke UrlEscape,Url,String,sizeof String,4000000h 
;invoke UrlCanonicalize,Url,String,sizeof String,4000000h

invoke MessageBox, NULL, addr String, ADDR mestitle, MB_ICONASTERISK
invoke ExitProcess,0

end start

and all dwflags don't include in inc???


qWord

So, what is the problem?
Maybe that you are passing invalid pointers for pszURL and pszEscaped?
FPU in a trice: SmplMath
It's that simple!

bomz

invoke UrlUnescape, addr Url, addr String,sizeof String,1000h
invoke MessageBox, NULL, addr String, ADDR mestitle, MB_ICONASTERISK


invoke UrlUnescape, Url, String,sizeof String,1000h
invoke MessageBox, NULL, addr String, ADDR mestitle, MB_ICONASTERISK


qWord

Quote from: msdnpcchEscaped [in, out]
        Type: DWORD*

        A pointer to a DWORD value ...

qWord
FPU in a trice: SmplMath
It's that simple!

dedndave

dwFlags = 1000h ???

URL_APPLY_FORCEAPPLY         EQU 0x00000008
URL_APPLY_GUESSFILE          EQU 0x00000004
URL_APPLY_GUESSSCHEME        EQU 0x00000002
URL_APPLY_DEFAULT            EQU 0x00000001
URL_WININET_COMPATIBILITY    EQU 0x80000000
URL_PLUGGABLE_PROTOCOL       EQU 0x40000000
URL_ESCAPE_UNSAFE            EQU 0x20000000
URL_UNESCAPE                 EQU 0x10000000
URL_DONT_SIMPLIFY            EQU 0x08000000
URL_NO_META                  EQU URL_DONT_SIMPLIFY
URL_ESCAPE_SPACES_ONLY       EQU 0x04000000
URL_DONT_ESCAPE_EXTRA_INFO   EQU 0x02000000
URL_DONT_UNESCAPE_EXTRA_INFO EQU URL_DONT_ESCAPE_EXTRA_INFO
URL_BROWSER_MODE             EQU URL_DONT_ESCAPE_EXTRA_INFO
URL_INTERNAL_PATH            EQU 0x00800000
URL_UNESCAPE_HIGH_ANSI_ONLY  EQU 0x00400000
URL_CONVERT_IF_DOSPATH       EQU 0x00200000
URL_UNESCAPE_INPLACE         EQU 0x00100000
URL_FILE_USE_PATHURL         EQU 0x00010000
URL_ESCAPE_SEGMENT_ONLY      EQU 0x00002000
URL_ESCAPE_PERCENT           EQU 0x00001000

you want URL_DONT_UNESCAPE_EXTRA_INFO and/or URL_UNESCAPE_INPLACE
then, your first code may work - those should be pointers


bomz

invoke UrlUnescape, Url, String,sizeof String,2001000h - empty
invoke UrlUnescape, addr Url, addr String,sizeof String,2001000h - error

qWord


URL_APPLY_FORCEAPPLY         EQU 00000008h
URL_APPLY_GUESSFILE          EQU 00000004h
URL_APPLY_GUESSSCHEME        EQU 00000002h
URL_APPLY_DEFAULT            EQU 00000001h
URL_WININET_COMPATIBILITY    EQU 80000000h
URL_PLUGGABLE_PROTOCOL       EQU 40000000h
URL_ESCAPE_UNSAFE            EQU 20000000h
URL_UNESCAPE                 EQU 10000000h
URL_DONT_SIMPLIFY            EQU 08000000h
URL_NO_META                  EQU URL_DONT_SIMPLIFY
URL_ESCAPE_SPACES_ONLY       EQU 04000000h
URL_DONT_ESCAPE_EXTRA_INFO   EQU 02000000h
URL_DONT_UNESCAPE_EXTRA_INFO EQU URL_DONT_ESCAPE_EXTRA_INFO
URL_BROWSER_MODE             EQU URL_DONT_ESCAPE_EXTRA_INFO
URL_INTERNAL_PATH            EQU 00800000h
URL_UNESCAPE_HIGH_ANSI_ONLY  EQU 00400000h
URL_CONVERT_IF_DOSPATH       EQU 00200000h
URL_UNESCAPE_INPLACE         EQU 00100000h
URL_FILE_USE_PATHURL         EQU 00010000h
URL_ESCAPE_SEGMENT_ONLY      EQU 00002000h
URL_ESCAPE_PERCENT           EQU 00001000h
.data
    szUrl db "http://mirror.yandex.ru/mozilla/firefox/releases/latest-4.0/win32/ru/Firefox%20Setup%204.0.exe",0
.data?
    szBuffer db INTERNET_MAX_URL_LENGTH dup (?)
    cbBuffer dd ?
.code

mov cbBuffer,SIZEOF szBuffer
invoke UrlEscape,ADDR szUrl,ADDR szBuffer,ADDR cbBuffer,URL_ESCAPE_SPACES_ONLY
FPU in a trice: SmplMath
It's that simple!

dedndave

the only flags that apply to that function are URL_DONT_UNESCAPE_EXTRA_INFO and/or URL_UNESCAPE_INPLACE
because they are not defined in the old include files of masm32, i would put something like this in my program...

IFNDEF URL_DONT_UNESCAPE_EXTRA_INFO
URL_DONT_UNESCAPE_EXTRA_INFO EQU 2000000h
ENDIF
IFNDEF URL_UNESCAPE_INPLACE
URL_UNESCAPE_INPLACE         EQU 100000h
ENDIF

that way, if you assemble the program with updated include files, you won't get an error

the values should be in shlwapi.inc
however, Hutch puts all his constants in windows.inc or winextra.inc

bomz


Quote
.386

.model flat, stdcall
option casemap :none

include \MASM32\INCLUDE\windows.inc
include \MASM32\INCLUDE\user32.inc
includelib \MASM32\LIB\user32.lib
include \MASM32\INCLUDE\kernel32.inc
includelib \MASM32\LIB\kernel32.lib
include \MASM32\INCLUDE\shlwapi.inc
includelib \MASM32\LIB\shlwapi.lib
   include \masm32\include\shell32.inc
   includelib \masm32\lib\shell32.lib

.data
mestitle    db " URL Convert ",0 ;переменная с заголовком
Url      db "http://mirror.yandex.ru/mozilla/firefox/releases/latest-4.0/win32/ru/Firefox%20Setup%204.0.exe",0

.data?
String db INTERNET_MAX_URL_LENGTH dup (?)
Buffer db INTERNET_MAX_URL_LENGTH dup (?)
cbBuffer dd ?

.code
start:

mov cbBuffer,SIZEOF String
invoke UrlUnescape, addr Url, addr String, addr cbBuffer,2001000h
invoke MessageBox, NULL, addr String, ADDR mestitle, MB_ICONASTERISK

invoke ExitProcess,0 ;завершаем программу

end start

qWord

.IFNDEF - this one is new to me  :bg
FPU in a trice: SmplMath
It's that simple!

dedndave

if not defined
oops - no period   :P

donkey

You should be defining any constants that are not in your include files. Also the size of the destination string is a pointer.

This one failed because bounds checking rejected the string pointer (Url)
invoke UrlUnescape, Url, String,sizeof String,2001000h - empty


This one failed because you passed sizeof String directly, it should have been a pointer to a DWORD containing the size
invoke UrlUnescape, addr Url, addr String,sizeof String,2001000h - error

qWord has been telling you your problem and a solution for many posts and you still have not fixed it, read the replies.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

this is what he needs for troubleshooting...
http://www.masm32.com/board/index.php?topic=13452.msg136501#msg136501

        invoke  UrlUnescape...........
        or      eax,eax
        jz      s_continue

        call    RegErr
        jmp     exit_program

s_continue: