News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

API trouble

Started by shankle, March 21, 2017, 09:50:59 AM

Previous topic - Next topic

shankle

                3-20-2017

.const
WIN32_FIND_DATA STRUCT
   dwFileAttributes DD
   ftCreationTime FILETIME
   ftLastAccessTime FILETIME
   ftLastWriteTime FILETIME
   nFileSizeHigh DD
   nFileSizeLow  DD
   dwReserved0   DD
   dwReserved1   DD
   cFileName TCHAR MAX_PATH DUP
   cAlternateFileName TCHAR 14 DUP
ENDS

DATA SECTION
BufAdd2       dq       0
hFile         dq       0
FACfromGFAF   db   '               ',0
FileDat       db   'D:\',0    ; msmbr
FSOutput      db   '                                                   ',0
tmsg14 db  'GetFileAttribute is invalid',0
tmsg15 db  'GetVolumeNameForVolumeMountPoint is valid',0
tmsg16 db  'GetVolumeNameForVolumeMountPoint is invalid',0
tmsg30 db  'File Attribute Constant from GetFileAttributes',0

WndProc:
    FRAME  hWnd,iMsg,wParam,lParam
    uses rbx,rdi,rsi
    LOCAL  cc:WIN32_FIND_DATA

.WM_CREATE
    cmp D[iMsg],WM_CREATE
     jne >>.WM_PAINT
    invoke GetDC, [hWnd]
    mov [hdc],rax
;   invoke GetVolumeNameForVolumeMountPoint, addr FileDat,addr FSOutput,50
    mov [hFile],rax

; test code begin
    cmp rax,0
    jg >>.gvftout1
    jle >>.gvftout2
.gvftout2

    invoke MessageBox, [hWnd], addr tmsg16,addr FSOutput, MB_OK ;true
    invoke ExitProcess, NULL
     jmp >>.GetOut
.gvftout1
    invoke MessageBox, [hWnd], addr tmsg15,addr FSOutput, MB_OK ;true
; This API worked
; test code END

    invoke GetFileAttributes, addr FSOutput

; test code begin
    cmp rax,INVALID_FILE_ATTRIBUTES
    je >>.gftout2
    jne >>.gftout1
.gftout2
    invoke MessageBox, [hWnd], addr tmsg14, addr tmsg14, MB_OK ;true
    invoke ExitProcess, NULL
     jmp >>.GetOut
.gftout1
    mov rcx,[cc.dwFileAttributes]         ; input
    lea rbx,FACfromGFAF ; output
    mov [BufAdd2],rbx
    invoke dwtoa, rcx,[BufAdd2]   ; Hex DD to string
                                 ; output is in FACfromGFAF
    invoke MessageBox, [hWnd], addr tmsg30, addr FACfromGFAF, MB_OK ;true
   This api worked but the data in FACfromGFAF is is not listed in the File
   Attributes Constants.
; test code END

   

wjr

Using input value loaded into rcx instead of the return value from GetFileAttributes in rax?

shankle

                3-21-2017

DATA SECTION
BufAdd2       dq       0
hFile         dq       0
FACfromGFAF   db   '               ',0
FileDat       db   'D:\',0    ; msmbr
FSOutput      db   '                                                   ',0
tmsg14 db  'GetFileAttribute is invalid',0
tmsg15 db  'GetVolumeNameForVolumeMountPoint is valid',0
tmsg16 db  'GetVolumeNameForVolumeMountPoint is invalid',0
tmsg30 db  'File Attribute Constant from GetFileAttributes',0

WndProc:
    FRAME  hWnd,iMsg,wParam,lParam

.WM_CREATE
    cmp D[iMsg],WM_CREATE
     jne >>.WM_PAINT
    invoke GetDC, [hWnd]
    mov [hdc],rax
   invoke GetVolumeNameForVolumeMountPoint, addr FileDat,addr FSOutput,50
    mov [hFile],rax

; test code begin
    cmp rax,0
    jg >>.gvftout1
    jle >>.gvftout2
.gvftout2

    invoke MessageBox, [hWnd], addr tmsg16,addr FSOutput, MB_OK ;true
    invoke ExitProcess, NULL
     jmp >>.GetOut
.gvftout1
    invoke MessageBox, [hWnd], addr tmsg15,addr FSOutput, MB_OK ;true
; This API worked
; test code END

    invoke GetFileAttributes, addr FSOutput

; test code begin
    cmp rax,0
    je >>.gftout2
    jne >>.gftout1
.gftout2
    invoke MessageBox, [hWnd], addr tmsg14, addr tmsg14, MB_OK ;true
    invoke ExitProcess, NULL
     jmp >>.GetOut
.gftout1
    mov rcx,rax         ; input
    lea rbx,FACfromGFAF ; output
    mov [BufAdd2],rbx
    invoke dwtoa, rcx,[BufAdd2]   ; Hex DD to string
                                 ; output is in FACfromGFAF
    invoke MessageBox, [hWnd], addr tmsg30, addr FACfromGFAF, MB_OK ;true
This API worked but the data in FACfromGFAF does not match any code in the
File Attribute Constants.
; test code END

   

wjr

I see you switched the INVALID_FILE_ATTRIBUTES to 0, so this time the function did fail and the 4294967295 or 0FFFFFFFFh or -1 is making it through to your MessageBox display instead of the invalid message. It would have failed for example if you had the call to GetVolumeNameForVolumeMountPoint commented out as in the first post above.

shankle

                3-22-2017

DATA SECTION
BufAdd2       dq       0
hFile         dq       0
FACfromGFAF   db   '               ',0
FileDat       db   'D:\',0    ; msmbr
FSOutput      db   '                                                   ',0
tmsg14 db  'GetFileAttribute is invalid',0
tmsg15 db  'GetVolumeNameForVolumeMountPoint is valid',0
tmsg16 db  'GetVolumeNameForVolumeMountPoint is invalid',0
tmsg30 db  'File Attribute Constant from GetFileAttributes',0

WndProc:
    FRAME  hWnd,iMsg,wParam,lParam

.WM_CREATE
    cmp D[iMsg],WM_CREATE
     jne >>.WM_PAINT
    invoke GetDC, [hWnd]
    mov [hdc],rax
   invoke GetVolumeNameForVolumeMountPoint, addr FileDat,addr FSOutput,50
    mov [hFile],rax

; test code begin
    cmp rax,0
    jg >>.gvftout1
    jle >>.gvftout2
.gvftout2

    invoke MessageBox, [hWnd], addr tmsg16,addr FSOutput, MB_OK ;true
    invoke ExitProcess, NULL
     jmp >>.GetOut
.gvftout1
    invoke MessageBox, [hWnd], addr tmsg15,addr FSOutput, MB_OK ;true
; This API worked
; test code END

    invoke GetFileAttributes, addr FSOutput

; test code begin
    cmp rax,INVALID_FILE_ATTRIBUTES
    je >>.gftout2
    jne >>.gftout1
.gftout2
    invoke MessageBox, [hWnd], addr tmsg14, addr tmsg14, MB_OK ;true
    invoke ExitProcess, NULL
     jmp >>.GetOut
.gftout1
    mov rcx,rax         ; input
    lea rbx,FACfromGFAF ; output
    mov [BufAdd2],rbx
    invoke dwtoa, rcx,[BufAdd2]   ; Hex DD to string
                                 ; output is in FACfromGFAF
    invoke MessageBox, [hWnd], addr tmsg30, addr FACfromGFAF, MB_OK ;true
This API worked but the data in FACfromGFAF does not match any code in the
File Attribute Constants.
Sorry about the coding errors. The corrected code is giving the same error as on
my previous attachment (2017-03-21_153023)
; test code END