Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLDownloadToCacheFileW and URLDownloadToFileW #30

Closed
GCuser99 opened this issue May 17, 2024 · 4 comments
Closed

URLDownloadToCacheFileW and URLDownloadToFileW #30

GCuser99 opened this issue May 17, 2024 · 4 comments
Labels
in-progress Issue resolved in source, pending for release. strings A problem with String arguments or LongPtrs representing them

Comments

@GCuser99
Copy link

These two should have String arguments changed to LongPtr I think:

Public Declare PtrSafe Function URLDownloadToCacheFileW Lib "urlmon" (ByVal lpUnkcaller As stdole.IUnknown, ByVal szURL As String, ByVal szFileName As LongPtr, ByVal dwBufLength As Long, ByVal dwReserved As Long, ByVal pbsc As IBindStatusCallback) As Long
Public Declare PtrSafe Function URLDownloadToFileW Lib "urlmon" (ByVal pCaller As stdole.IUnknown, ByVal szURL As String, ByVal szFile As String, ByVal dwReserved As Long, ByVal lpfnCB As IBindStatusCallback) As Long
@fafalone
Copy link
Owner

Well thats annoying; I made those changes and somehow they didn't take... maybe forgot to save, or tB did that fakeout...

Fixed in v8.0.404, available now.

Hey is this something regex would be able to help with? If so, if you're up for it and whenever you have the time, could you check for other W functions that have String arguments but not DeclareWide?

@fafalone fafalone added the strings A problem with String arguments or LongPtrs representing them label May 17, 2024
@GCuser99
Copy link
Author

GCuser99 commented May 17, 2024

I ran the search for unAliased W's with String Args and included in list below. For each of those found, I also examined their corresponding A and Aliased siblings and included what looked to be incorrect in those too (for example, some A/W versions were misidentified as W/A respectively).

Public Declare PtrSafe Function CommandLineToArgvW Lib "shell32" (ByVal lpCmdLine As String, pNumArgs As Long) As LongPtr

'the DeclareWide Aliased version has LongPtr that should be String
Public DeclareWide PtrSafe Function PathIsSystemFolder Lib "shlwapi" Alias "PathIsSystemFolderW" (ByVal pszPath As LongPtr, ByVal dwAttrb As Long) As BOOL
Public Declare PtrSafe Function PathIsSystemFolderW Lib "shlwapi" (ByVal pszPath As String, ByVal dwAttrb As Long) As BOOL

Public Declare PtrSafe Function UrlCreateFromPathW Lib "shlwapi" (ByVal pszPath As String, ByVal pszUrl As String, ByRef pcchUrl As Long, ByVal dwFlags As Long) As Long

'the Aliased version should be DeclareWide and lpsz arg switched to String
Public Declare PtrSafe Function IsBadStringPtr Lib "kernel32" Alias "IsBadStringPtrW" (ByVal lpsz As LongPtr, ByVal ucchMax As LongPtr) As BOOL
Public Declare PtrSafe Function IsBadStringPtrW Lib "kernel32" (ByVal lpsz As String, ByVal ucchMax As LongPtr) As BOOL

Public Declare PtrSafe Function CreateWaitableTimerExW Lib "kernel32" (lpTimerAttributes As SECURITY_ATTRIBUTES, ByVal lpTimerName As String, ByVal dwFlags As CreateWaitableTimerExFlags, ByVal dwDesiredAccess As Long) As LongPtr

'switch the args between W and A versions?
Public Declare PtrSafe Function CreateServiceA Lib "advapi32" (ByVal hService As LongPtr, ByVal lpServiceName As LongPtr, ByVal lpDisplayName As LongPtr, ByVal dwDesiredAccess As Long, ByVal dwServiceType As ServiceType, ByVal dwStartType As ServiceStartType, ByVal dwErrorControl As ServiceErrorControlType, Optional ByVal lpBinaryPathName As LongPtr, Optional ByVal lpLoadOrderGroup As LongPtr, Optional ByRef lpdwTagId As Long, Optional ByVal lpDependencies As LongPtr, Optional ByVal lpServiceStartName As LongPtr, Optional ByVal lpPassword As LongPtr) As BOOL
Public Declare PtrSafe Function CreateServiceW Lib "advapi32" (ByVal hService As LongPtr, ByVal lpServiceName As LongPtr, ByVal lpDisplayName As LongPtr, ByVal dwDesiredAccess As Long, ByVal dwServiceType As ServiceType, ByVal dwStartType As ServiceStartType, ByVal dwErrorControl As ServiceErrorControlType, Optional ByVal lpBinaryPathName As String, Optional ByVal lpLoadOrderGroup As String, Optional ByRef lpdwTagId As Long, Optional ByVal lpDependencies As String, Optional ByVal lpServiceStartName As String, Optional ByVal lpPassword As String) As BOOL

Public Declare PtrSafe Function mmioRenameW Lib "winmm" (ByVal szFileName As LongPtr, ByVal SzNewFileName As String, lpmmioinfo As MMIOINFO, ByVal dwRenameFlags As Long) As MMIOERR

Public Declare PtrSafe Function GetPrintProcessorDirectoryW Lib "winspool.drv" (ByVal pName As LongPtr, ByVal pEnvironment As LongPtr, ByVal Level As Long, ByVal pPrintProcessorInfo As String, ByVal cbBuf As Long, pcbNeeded As Long) As BOOL

Public Declare PtrSafe Function SetFormW Lib "winspool.drv" (ByVal hPrinter As LongPtr, ByVal pFormName As String, ByVal Level As Long, pForm As Any) As BOOL

'switch the args between W and A versions?
Public Declare PtrSafe Function AddPortA Lib "winspool.drv" (ByVal pName As LongPtr, ByVal hwnd As LongPtr, ByVal pMonitorName As LongPtr) As BOOL
Public Declare PtrSafe Function AddPortW Lib "winspool.drv" (ByVal pName As String, ByVal hwnd As LongPtr, ByVal pMonitorName As String) As BOOL

'these two do not have corresponding A and Aliased W    
Public Declare PtrSafe Function CredUIStoreSSOCredW Lib "credui.dll" (ByVal pszRealm As String, ByVal pszUsername As String, ByVal pszPassword As String, ByVal bPersist As BOOL) As Long
Public Declare PtrSafe Function CCredUIReadSSOCredW Lib "credui.dll" (ByVal pszRealm As String, ppszUsername As LongPtr) As Long

Public Declare PtrSafe Function GetUrlCacheEntryInfoExW Lib "wininet" (ByVal lpszUrl As LongPtr, lpCacheEntryInfo As INTERNET_CACHE_ENTRY_INFOW, lpcbCacheEntryInfo As Long, ByVal lpszRedirectUrl As String, lpcbRedirectUrl As Long, ByVal lpReserved As LongPtr, ByVal dwFlags As Long) As BOOL

'these two do not have corresponding A and Aliased W   
Public Declare PtrSafe Function PrivacySetZonePreferenceW Lib "wininet" (ByVal dwZone As URLZONE, ByVal dwType As PrivacyType, ByVal dwTemplate As INET_PRIVACY_TEMPLATES, Optional ByVal pszPreference As String) As Long
Public Declare PtrSafe Function PrivacyGetZonePreferenceW Lib "wininet" (ByVal dwZone As URLZONE, ByVal dwType As PrivacyType, pdwTemplate As INET_PRIVACY_TEMPLATES, Optional ByVal pszBuffer As String, Optional pdwBufferLength As Long) As Long

@fafalone
Copy link
Owner

There's no CredUIStoreSSOCred[A} defined in the Windows API, same for the one below that, and PrivacyGet/SetZonePreferenceW, and the CmdLine...-- but there's only 1 C at the start of CredUIReadSSOCredW so glad that was caught. I'm going to use overloads so either String or LongPtr can be used with W.

Thanks again, really great working finding all these bugs 💯

@fafalone fafalone added the in-progress Issue resolved in source, pending for release. label May 18, 2024
@fafalone
Copy link
Owner

All identified issues fixed in v8.0.406, available now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-progress Issue resolved in source, pending for release. strings A problem with String arguments or LongPtrs representing them
Projects
None yet
Development

No branches or pull requests

2 participants