The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: bomz on April 19, 2011, 12:23:58 PM

Title: Type: PCTSTR & PTSTR
Post by: bomz on April 19, 2011, 12:23:58 PM
http://msdn.microsoft.com/en-us/library/bb773774%28v=VS.85%29.aspx     (http://smiles.kolobok.us/light_skin/unknw.gif)
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  (http://smiles.kolobok.us/light_skin/suicide2.gif)
;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???
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 19, 2011, 01:49:09 PM
(http://smiles.kolobok.us/light_skin/cray.gif)
Title: Re: Type: PCTSTR & PTSTR
Post by: qWord on April 19, 2011, 02:13:08 PM
So, what is the problem?
Maybe that you are passing invalid pointers for pszURL and pszEscaped?
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 19, 2011, 02:24:44 PM
invoke UrlUnescape, addr Url, addr String,sizeof String,1000h
invoke MessageBox, NULL, addr String, ADDR mestitle, MB_ICONASTERISK
(http://s45.radikal.ru/i107/1104/da/b927290bbb2d.png)
(http://s007.radikal.ru/i301/1104/3e/740303e48254.png)
invoke UrlUnescape, Url, String,sizeof String,1000h
invoke MessageBox, NULL, addr String, ADDR mestitle, MB_ICONASTERISK
(http://s004.radikal.ru/i206/1104/fc/ce744485d1a4.png)
Title: Re: Type: PCTSTR & PTSTR
Post by: qWord on April 19, 2011, 02:34:10 PM
Quote from: msdnpcchEscaped [in, out]
        Type: DWORD*

        A pointer to a DWORD value ...

qWord
Title: Re: Type: PCTSTR & PTSTR
Post by: dedndave on April 19, 2011, 02:36:49 PM
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
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 19, 2011, 02:40:28 PM
(http://i049.radikal.ru/1104/7f/d6906858efad.png)
(http://s55.radikal.ru/i150/1104/a4/b0afddeaa3f1.png)
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 19, 2011, 02:47:28 PM
invoke UrlUnescape, Url, String,sizeof String,2001000h - empty
invoke UrlUnescape, addr Url, addr String,sizeof String,2001000h - error
Title: Re: Type: PCTSTR & PTSTR
Post by: qWord on April 19, 2011, 02:53:06 PM

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
Title: Re: Type: PCTSTR & PTSTR
Post by: dedndave on April 19, 2011, 02:55:32 PM
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
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 19, 2011, 02:58:11 PM
(http://smiles.kolobok.us/light_skin/dance4.gif)
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
(http://smiles.kolobok.us/light_skin/thank_you2.gif)
Title: Re: Type: PCTSTR & PTSTR
Post by: qWord on April 19, 2011, 02:58:36 PM
.IFNDEF - this one is new to me  :bg
Title: Re: Type: PCTSTR & PTSTR
Post by: dedndave on April 19, 2011, 02:59:32 PM
if not defined
oops - no period   :P
Title: Re: Type: PCTSTR & PTSTR
Post by: donkey on April 19, 2011, 03:03:52 PM
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.
Title: Re: Type: PCTSTR & PTSTR
Post by: dedndave on April 19, 2011, 03:05:37 PM
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:
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 24, 2011, 05:50:21 PM
invoke UrlUnescape, eax, addr String, addr cbBuffer,2010000h

convert %20 to space OK. but why it don't convert other signs? what flags need?

http://www.microsoft.com/downloads/info.aspx?na=41&SrcFamilyId=C3A8CEC0-F947-4D4E-A6AE-C7F4F1F311B0&SrcDisplayLang=ru&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f5%2f9%2fE%2f59EB3D55-FFC7-4F7C-BEBF-3DB3C3B0F644%2fWindowsXP-KB2497640-x86-RUS.exe
Title: Re: Type: PCTSTR & PTSTR
Post by: dedndave on April 24, 2011, 06:03:07 PM
IFNDEF URL_UNESCAPE_INPLACE
URL_UNESCAPE_INPLACE EQU 100000h
ENDIF
;
;
;
        INVOKE  UrlUnescape,eax,addr String,addr cbBuffer,URL_UNESCAPE_INPLACE


you told it not to unescape extra data
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 24, 2011, 06:04:14 PM
Thanks. I don't see all this falgs in MSDN and think to ask except try all flags
Title: Re: Type: PCTSTR & PTSTR
Post by: dedndave on April 24, 2011, 06:05:39 PM
yah - you have to google around a little bit   :P
but, it's defined in Shlwapi.h
Title: Re: Type: PCTSTR & PTSTR
Post by: dedndave on April 24, 2011, 06:07:09 PM
actually, because you are using 2 seperate buffers, i think you might try this...
        INVOKE  UrlUnescape,eax,addr String,addr cbBuffer,NULL
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 24, 2011, 06:11:46 PM
OK . (http://smiles.kolobok.us/light_skin/thank_you2.gif)
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 24, 2011, 07:19:50 PM
Quote
invoke InternetSetFilePointer, hUrl, FilePointerMoveLow, NULL, FilePointerMoveHigh, FILE_BEGIN, NULL
.if eax == INVALID_SET_FILE_POINTER
invoke MessageBox,0,0,0,0
.endif
(http://s54.radikal.ru/i144/1104/b4/c30c843eb869.png)
Quote
invoke InternetSetFilePointer, hUrl, FilePointerMoveLow, NULL, FilePointerMoveHigh, FILE_BEGIN;, NULL
.if eax == INVALID_SET_FILE_POINTER
invoke MessageBox,0,0,0,0
OK
http://msdn.microsoft.com/en-us/library/aa385113%28v=vs.85%29.aspx
Quote
DWORD InternetSetFilePointer(
  __in     HINTERNET hFile,
  __in     LONG lDistanceToMove,
  __in     PVOID pReserved,
  __inout  PLONG lpDistanceToMoveHigh,
  __in     DWORD dwMoveMethod,
  __in     DWORD_PTR dwContext
);


This is error in MASM include file???
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 24, 2011, 07:27:43 PM
include \MASM32\include\wininet.inc
Quote
InternetSetFilePointer PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
and if this is the error how decide which parameter is lost. may be add one? ,:DWORD  (http://smiles.kolobok.us/light_skin/scratch_one-s_head.gif)

Quote
InternetSetFilePointer PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
(http://s016.radikal.ru/i335/1104/54/ac3e91baeeac.png)
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 24, 2011, 08:08:01 PM
Quoteinvoke InternetSetFilePointer, hUrl, NULL, NULL, FILE_CURRENT, NULL
.if eax == INVALID_SET_FILE_POINTER
invoke MessageBox,0,0,0,0
.endif
   invoke wsprintf,addr Buffer,Mess,eax
   invoke MessageBox, NULL, addr Buffer, NULL, MB_ICONASTERISK

THIS PARAMETRE IS LOST
QuotepReserved [in]

    This parameter is reserved and must be NULL.
(http://s41.radikal.ru/i092/1104/1f/51354f9a4f8c.gif)
Title: Re: Type: PCTSTR & PTSTR
Post by: dedndave on April 24, 2011, 09:16:50 PM
it appears as though InternetSetFilePointer is improperly PROTOtype in wininet.inc
according to MSDN, it has 6 dword parameters:
DWORD InternetSetFilePointer(
  __in     HINTERNET hFile,
  __in     LONG lDistanceToMove,
  __in     PVOID pReserved,
  __inout  PLONG lpDistanceToMoveHigh,
  __in     DWORD dwMoveMethod,
  __in     DWORD_PTR dwContext
);


but, if we look in wininet.inc, it only has 5:
InternetSetFilePointer PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD

i would modify wininet.inc and make a note of it
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 24, 2011, 09:28:12 PM
Where I may download version of MASM32 with ALL modification? Here http://www.masm32.com/masmdl.htm the version which I download some(?) years ago
Title: Re: Type: PCTSTR & PTSTR
Post by: dedndave on April 24, 2011, 11:28:44 PM
we have all been waiting patiently for Hutch to update it   :bg

when you find these kinds of errors, it's good to create a thread in this sub-forum:
http://www.masm32.com/board/index.php?board=7.0
(note: i searched that subform first thing to see if it had been mentioned)
that's not necessarily a guarantee that it will get added - lol
but, when someone uses the advanced search tool (limits search to that sub-form), they can find corrected information
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 25, 2011, 07:46:42 AM
One LITTLE question. I make download manager, as you may understand already, I find a lot of examples how download file from internet using WinInet, but I have a problem - my program can't download files approximately more than 2 gig from quick servers - LOCAL for me. What may be a reason of this? I may download small (700-1000+mb) files from this server, I may download 4 gig files from NOTLOCAL servers...
InternetReadFile read 0 bytes.
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 25, 2011, 08:52:29 PM
Something else - FtpGetFileSize don't back highword of file size. Somebody use WinInet. all OK in masm32 with wininet?

Quote
   .386
   .model flat,stdcall
   option casemap:none

   include \masm32\include\windows.inc
   include \masm32\include\user32.inc
   include \masm32\include\kernel32.inc
   include \masm32\include\wininet.inc
   includelib \masm32\lib\user32.lib
   includelib \masm32\lib\kernel32.lib
   includelib \masm32\lib\wininet.lib

.data
   UserAgent   db 'Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.0; .NET CLR 1.0.2914)',0
form            db 'Size %u',0
AReg            WORD64 ?
BReg            LONG64 ?
CReg            dt ?
DReg            dt ?

   site_name   db 'ftp.site.com',0
   file_name   db 'Detektiv.Di.2010.x264.BDRip.720p.mkv',0
   user_name   db 'anonymous',0
   password   db '111111',0

.data?
   hInternet   dd ?
   hConnect   dd ?
   hRequest   dd ?
   Bufferlen   dd ?
   Buffer      db 65536 dup(?)
   fHand      dd ?
   bwrite      dd ?

.code
start:

   invoke InternetOpen, addr UserAgent,INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL
        test eax, eax
        jz exit1
   mov hInternet,eax
   invoke InternetConnect,hInternet, addr site_name,INTERNET_DEFAULT_FTP_PORT, addr user_name, addr password,INTERNET_SERVICE_FTP, 0, 0
        test eax, eax
        jz exit2
   mov hConnect,eax
   invoke FtpOpenFile, hConnect, addr file_name, GENERIC_READ, INTERNET_FLAG_TRANSFER_BINARY, NULL
   mov hRequest,eax
        test eax, eax
        jz exit3
   invoke FtpGetFileSize,hRequest, addr Bufferlen
   mov dword ptr[BReg], eax

   invoke wsprintf,addr Buffer,addr form, Bufferlen
   invoke MessageBox, NULL, addr Buffer, addr site_name, MB_ICONASTERISK
;invoke MessageBox,0,0,0,0
   invoke InternetCloseHandle, hRequest
exit3:

   invoke InternetCloseHandle, hConnect
exit2:

   invoke InternetCloseHandle, hInternet
exit1:

   invoke ExitProcess,eax
end start
Title: Re: Type: PCTSTR & PTSTR
Post by: qWord on April 25, 2011, 09:35:53 PM
So what did it return for the high order DWORD? For each file smaller than ~4.2GB it should return zero.
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 25, 2011, 10:01:08 PM
ZERO for any size
(http://i014.radikal.ru/1104/b0/ce559cae39df.png)(http://s1.ipicture.ru/uploads/20110426/W2BSLvS1.png) (http://s1.ipicture.ru/uploads/20110426/lCi3VOqz.png) (http://s1.ipicture.ru/uploads/20110426/WjQ2kWrq.png) (http://s1.ipicture.ru/uploads/20110426/YLgeWcP5.png)

HighWord always zero , LowWord divided 10-100.....
Title: Re: Type: PCTSTR & PTSTR
Post by: qWord on April 25, 2011, 11:50:19 PM
Maybe an firewall problem. Normally it should work - you may attache some example app for testing purpose.
Title: Re: Type: PCTSTR & PTSTR
Post by: bomz on April 26, 2011, 07:20:53 AM
No firewall, no antivirus. FTP is local (127.0.0.1) I can't find public FTP with files bigger 4 G. May be WinInet work uncorrect and all download managers made with SOCKET? GOOGLE don't say anoothing about WinInet problem, most examples in Internet - Delphi and C+.

ftp://dispenser.yandex.net/asplinux/i386/14/ASPLinux-14-i386-DVD.iso

dispenser.yandex.net
/asplinux/i386/14/ASPLinux-14-i386-DVD.iso
4187672576 b