Author Topic: Number and type of arguments required for call to C library  (Read 49443 times)

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Number and type of arguments required for call to C library
« Reply #120 on: June 05, 2014, 02:41:46 AM »
the stuff you put into the ZipIt folder will be zipped
so, for test purposes, i put a text file, and a folder containing a text file into the ZipIt folder

That makes things a bit clearer.

Gunther
Get your facts first, and then you can distort them.

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Number and type of arguments required for call to C library
« Reply #121 on: June 05, 2014, 03:15:10 AM »
sorry - i made a mistake on that last attachment

Code: [Select]
  UCSTR   bstrPathSource, "C:\masm32\include",0 ;"C:\ZipTest\ZipIt",0
for testing, i zipped the contents of the include folder
but, i forgot to remove the test string   :(

Code: [Select]
  UCSTR   bstrPathSource, "C:\ZipTest\ZipIt",0
so, the ISDZip4.zip update fixes that issue (Reply #111)

jj2007

  • Member
  • *****
  • Posts: 9644
  • Assembler is fun ;-)
    • MasmBasic
Re: Number and type of arguments required for call to C library
« Reply #122 on: June 05, 2014, 08:28:38 AM »
Reply #111 still doesn't work for me, the NameSpace thingy fails :(
I also don't see the compressed folder option when I right-click on a file; regsvr32 zipfldr.dll didn't help (yes, I rebooted).

I'd love to have a 3rd party independent zipper. Unzipping works like a charm now with a wrapper for Jørgen Ibsen's tiny inflate (tinf) library:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  SetCpUtf8            ; filenames in zipfiles are UTF-8 encoded, so we force codepage UTF-8
  Print "*** Attention: Your console may not be able to display all Unicode file names correctly ***", CrLf$, CrLf$
  Print cStyle$("#\tSize\tDate\t\tTime\tFilename\n")
  UnzipInit "\Masm32\MasmBasic\Res\UnicodeTest.zip"
  ; UnzipInit returns a comment or an empty string in eax, the #files in edx, and the Sign? flag to signal an error
  .if Sign?
      Print eax      ; if the sign flag is set, eax points to an error message
  .else
      push eax      ; save the comment returned by UnzipInit
      For_ ecx=0 To edx-1
            PrintLine Str$(ecx+1), Tb$, Str$(GfSize(ecx)), Tb$, GfDate$(ecx), Spc2$, GfTime$(ecx), Tb$, Files$(ecx)
      Next
      pop eax
      PrintLine "Zipfile comment:", CrLf$, eax
      .While 1
            Inkey At(0, 15) "Enter the number of the file you want to see, or Escape to exit", CrLf$, CrLf$, "File #: ", Space$(40)
            .Break .if eax==VK_ESCAPE
            lea ecx, [eax-"1"]
            .if ecx<=Files$(?)
                  Locate(10, 17)
                  Print " ", Files$(ecx)       ; erase rest of previous filename
                  FileWrite Files$(ecx), UnzipFile(ecx), GfLastWrite(ecx)      ; restore the file, and don't forget the timestamp
                  Launch Cat$("..\RichMasm.exe "+Files$(ecx)+"#UTF")
            .endif
      .Endw
      UnzipExit      ; cleanup
  .endif
  Exit
end start


One hilarious thing is that you need at least two archivers to do simple things like adding files or comments:
- 7-Zip to add and delete files
- WinZip to add comments

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Number and type of arguments required for call to C library
« Reply #123 on: June 05, 2014, 12:26:39 PM »
it seems like unzipping is by far the more difficult task
there are so many different flavours of zip files   :redface:

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Number and type of arguments required for call to C library
« Reply #124 on: June 05, 2014, 04:23:27 PM »
it seems like unzipping is by far the more difficult task
there are so many different flavours of zip files   :redface:

yes, indeed. There are historical reasons for that. One reason is the Welch patent.

Gunther
Get your facts first, and then you can distort them.

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Number and type of arguments required for call to C library
« Reply #125 on: June 05, 2014, 08:26:07 PM »
yah - and, it has evolved over about 30 years - lol

the unzip algorithm is probably very simple, compared to the zip algo

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: Number and type of arguments required for call to C library
« Reply #126 on: June 06, 2014, 05:06:26 AM »
One reason is the Welch patent.

Shouldn’t that be “was the Welch patent”?
Well Microsoft, here’s another nice mess you’ve gotten us into.

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Number and type of arguments required for call to C library
« Reply #127 on: June 06, 2014, 05:21:46 AM »
Michael,

Shouldn’t that be “was the Welch patent”?

yes, of course. It's history now, but it wasn't during the 90s.

Gunther
Get your facts first, and then you can distort them.

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Number and type of arguments required for call to C library
« Reply #128 on: June 06, 2014, 05:55:42 AM »
we have been trying to mimic the drag-n-drop method (i guess it's a drop target)
maybe we want to mimic the Send To shell extension, instead
although - that won't give us any control over the dialogs that may appear
it may give us insight as to the "right" way to know when the copy is done

the file lock method that i mentioned earlier may not work very well
at this point, the thread method seems best - but doesn't seem ideal, either

adeyblue

  • Member
  • **
  • Posts: 89
    • Airesoft
Re: Number and type of arguments required for call to C library
« Reply #129 on: June 06, 2014, 06:26:02 AM »
@adeyblue: pShellDisp->NameSpace(varOutDir, &pOutFolder) failed with error 0x80004005 :(

Strange. I'm sure I tried it and it worked before I posted it. But trying it just now and it doesn't just not work, none of the functions fail, and it just straight up crashes. Anyway, I've updated it and tried it and fingers crossed it's good to go now (on Win7 x64).

EDIT: Or not. Argh! Seems MS don't want you using pidls in VARIANT's. In XP the type Namespace() wants is VT_ARRAY | VT_UI1, in 7 that's changed to VT_VECTOR | VT_UI1. Just to make matters worse, 7 has reused VT_ARRAY | VT_UI1 to mean a completely different structure. So I'll go revert the code back to using names.

we have been trying to mimic the drag-n-drop method (i guess it's a drop target)
maybe we want to mimic the Send To shell extension, instead
Do you shoot messengers around here? Send To is yet another wrapper around drag & drop, at least in the case of zipfldr.

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: Number and type of arguments required for call to C library
« Reply #130 on: June 06, 2014, 07:14:02 AM »
we have been trying to mimic the drag-n-drop method (i guess it's a drop target)
...
I think that it was adeyblue who has been trying to mimic the drag-n-drop method in his article.
We were using top level scriptable shell interfaces and two their methods: NameSpace and CopyHere.
The main problem was to wait for shell's threads termination . I've never debugged multythreaded applications  before .  It was an exciting quest .

...
maybe we want to mimic the Send To shell extension, instead
...
Sure ! A day or two ago I was playing with powershell  thinking about this method .
So here's the sequence of actions  in short:
creating Shell object -> NameSpace("C:\ZIPIT") ->ParseName("test.asm") -> now that we have IFolderItem object for out test file   we want to see its Verbs -> IFolderItem ::Verbs -> now I dumped the result (count of verbs =15) ,there were all those items that you see when cklicking RMB  ... EXCEPT Send To ... (I remember it was #8 - an empty line )  .
Problem #1: how to find Send To submenu of the context menu and parse its options
Problem #2: what if there's no "Zip folder" option in the "Send to"  submenu ? Should we register it ? How?   

Also I was thinking about creating custom drop target like that empty file on the desktop with .zfSendToTraget  extension which zips everything that you drag'n'drop on it . 




dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Number and type of arguments required for call to C library
« Reply #131 on: June 06, 2014, 08:18:46 AM »
i don't think our "final" solution will be to use the Send To mechanism
however, we might be able to gain some insight from watching it   :P
that takes care of problem #2

problem #1 is a little tricky
but, we should be able to follow the chain through the registry
a couple ways come to mind:
1) dredge through the registry chain
2) pretend we want to write a Send To shell extension and see how it works - lol

one of the zipfldr.dll resources is an INF file that registers it
Code: [Select]
[Version]
Signature="$CHICAGO$"
[RegAlways]
AddReg=ZipFldr.RegAlways
DelReg=Delete.RegAlways
RequiredEngine=SETUPAPI,%ERR_NOSETUPAPI%
[RegTakeDefault]
AddReg=ZipFldr.RegTakeDefault
DelReg=Delete.RegTakeDefault
RequiredEngine=SETUPAPI,%ERR_NOSETUPAPI%
[Unreg]
DelReg=ZipFldr.RegAlways,ZipFldr.RegTakeDefault
[ZipFldr.RegTakeDefault]
HKCR,.zip,,,CompressedFolder
HKCR,.zip,"Content Type",,"application/x-zip-compressed"
[Delete.RegTakeDefault]
[ZipFldr.RegAlways]
HKCR,CLSID\%CLSID_ZIPFLD%,,,CompressedFolder
HKCR,CLSID\%CLSID_ZIPFLD%\DefaultIcon,,%REGEXSZ%,%_SYS_MOD_PATH%
HKCR,CLSID\%CLSID_ZIPFLD%\InProcServer32,,%REGEXSZ%,%_SYS_MOD_PATH%
HKCR,CLSID\%CLSID_ZIPFLD%\InProcServer32,ThreadingModel,,Apartment
HKCR,CLSID\%CLSID_ZIPFLD%\ProgID,,,CompressedFolder
HKCR,CLSID\%CLSID_ZIPFLD%\ShellFolder,Attributes,%REGDW%,0x200001a0
HKCR,CLSID\%CLSID_ZIPFLD%\ShellFolder,UseDropHandler,,
HKCR,.zip\OpenWithProgids,CompressedFolder
HKCR,.zip\CompressedFolder\ShellNew,Data,%REGBINARY%,50,4B,05,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
HKCR,"Applications\zipfldr.dll",NoOpenWith,,
HKCR,CompressedFolder,,,"%COMPRESSED_FOLDER%"
HKCR,CompressedFolder,"FriendlyTypeName",%REGEXSZ%,"@%_SYS_MOD_PATH%,-10195"
HKCR,CompressedFolder\CLSID,,,%CLSID_ZIPFLD%
HKCR,"SystemFileAssociations\.zip\CLSID",,,%CLSID_ZIPFLD%
HKCR,CompressedFolder\DefaultIcon,,%REGEXSZ%,%_SYS_MOD_PATH%
HKCR,CompressedFolder\Shell\Open\Command,,,"rundll32.exe zipfldr.dll,RouteTheCall %%L"
HKCR,"CompressedFolder\shell\open",BrowserFlags,%REGDW%,0x0010
HKCR,"CompressedFolder\shell\open",ExplorerFlags,%REGDW%,0x0012
HKCR,CompressedFolder\Shell\Open\ddeexec,,,"[ViewFolder(""%%l"", %%I, %%S)]"
HKCR,CompressedFolder\Shell\Open\ddeexec,NoActivateHandler
HKCR,CompressedFolder\Shell\Open\ddeexec\application,,,"Folders"
HKCR,CompressedFolder\Shell\Open\ddeexec\ifexec,,,"[]"
HKCR,CompressedFolder\Shell\Open\ddeexec\topic,,,"AppProperties"
HKCR,CompressedFolder\shell\find,SuppressionPolicy,%REGDW%,0x00000080
HKCR,CompressedFolder\shell\find\command,,%REGEXSZ%,"%25%\Explorer.exe"
HKCR,CompressedFolder\shell\find\ddeexec,,,"[FindFolder(""%l"", %I)]"
HKCR,CompressedFolder\shell\find\ddeexec\application,,,"Folders"
HKCR,CompressedFolder\shell\find\ddeexec\topic,,,"AppProperties"
HKCR,CompressedFolder\ShellEx\ContextMenuHandlers\%CLSID_ZIPCONTEXTMENU%,,,"Compressed (zipped) Folder Menu"
HKCR,CompressedFolder\ShellEx\DropHandler,,,"%CLSID_ZipFolderDropHandler%"
HKCR,CompressedFolder\ShellEx\StorageHandler,,,"%CLSID_ZIPFLD%"
HKCR,MIME\Database\Content Type\application/x-zip-compressed,"Extension",,".zip"
HKCR,CLSID\%CLSID_ZIPDRAG%,,,"Compressed (zipped) Folder Right Drag Handler"
HKCR,CLSID\%CLSID_ZIPDRAG%\InProcServer32,,%REGEXSZ%,%_SYS_MOD_PATH%
HKCR,CLSID\%CLSID_ZIPDRAG%\InProcServer32,"ThreadingModel",,"Apartment"
HKCR,Folder\shellex\DragDropHandlers\%CLSID_ZIPDRAG%
HKCR,CLSID\%CLSID_ZIPSENDTO%,,,"Compressed (zipped) Folder SendTo Target"
HKCR,CLSID\%CLSID_ZIPSENDTO%,"FriendlyTypeName",%REGEXSZ%,"@%_SYS_MOD_PATH%,-10226"
HKCR,CLSID\%CLSID_ZIPSENDTO%\InProcServer32,,%REGEXSZ%,%_SYS_MOD_PATH%
HKCR,CLSID\%CLSID_ZIPSENDTO%\InProcServer32,"ThreadingModel",,"Apartment"
HKCR,CLSID\%CLSID_ZIPSENDTO%\DefaultIcon,,%REGEXSZ%,%_SYS_MOD_PATH%
HKCR,CLSID\%CLSID_ZIPSENDTO%\ShellEx\DropHandler,,,"%CLSID_ZIPSENDTO%"
HKCR,CLSID\%CLSID_ZIPSENDTO%,NeverShowExt
HKCR,CLSID\%CLSID_ZIPSENDTO%,NoOpen,,"%NOOPEN%"
HKCR,CLSID\%CLSID_ZIPSENDTO%,EditFlags,%REGDW%,0x00000001
HKCR,CLSID\%CLSID_ZIPCONTEXTMENU%,,,"Compressed (zipped) Folder Context Menu"
HKCR,CLSID\%CLSID_ZIPCONTEXTMENU%\InProcServer32,,%REGEXSZ%,%_SYS_MOD_PATH%
HKCR,CLSID\%CLSID_ZIPCONTEXTMENU%\InProcServer32,"ThreadingModel",,"Apartment"
HKCR,CLSID\%CLSID_ZipFolderDropHandler%,,,"Compressed (zipped) Folder DropHandler"
HKCR,CLSID\%CLSID_ZipFolderDropHandler%\InProcServer32,,%REGEXSZ%,%_SYS_MOD_PATH%
HKCR,CLSID\%CLSID_ZipFolderDropHandler%\InProcServer32,"ThreadingModel",,"Apartment"
HKCR,.ZFSendToTarget,,,CLSID\%CLSID_ZIPSENDTO%
HKLM,"Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved",%CLSID_ZIPFLD%,,"%COMPRESSED_FOLDER%"
HKLM,"Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved",%CLSID_ZIPDRAG%,,"Compressed (zipped) Folder Right Drag Handler"
HKLM,"Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved",%CLSID_ZIPSENDTO%,,"Compressed (zipped) Folder SendTo Target"
[Delete.RegAlways]
HKCR,CLSID\%CLSID_ZIPFLD%\shellex\ExtShellFolderViews
HKCR,CompressedFolder\ShellEx\ContextMenuHandlers\%CLSID_ZIPFLD%
HKCR,CompressedFolder\Shell\Explore
[Strings]
REGDW=0x00010001
REGEXSZ=0x00020000
REGBINARY=0x00000001
CLSID_ZIPFLD={E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}
CLSID_ZIPDRAG={BD472F60-27FA-11cf-B8B4-444553540000}
CLSID_ZIPSENDTO={888DCA60-FC0A-11CF-8F0F-00C04FD7D062}
CLSID_ZIPCONTEXTMENU={b8cdcb65-b1bf-4b42-9428-1dfdb7ee92af}
CLSID_ZipFolderDropHandler={ed9d80b9-d157-457b-9192-0e7280313bf0}
COMPRESSED_FOLDER = "Compressed (zipped) Folder"
NOOPEN="Drag Files onto this icon to compress them."
ERR_NOSETUPAPI="Can not register ZIPFLDR.DLL because SETUPAPI.DLL is missing."
[End]

looking at the code, it seems that it creates a COM interface
it would take some time to wade through it

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: Number and type of arguments required for call to C library
« Reply #132 on: June 06, 2014, 10:31:23 PM »
I'm totally agree
Below I bookmarked several msdn Shell references for further reading
Shell Developer's Guide
Working with Shell Extensions
Creating Shell Extension Handlers
Registering Shell Extension Handlers

Well , adding "Compressed (zipped) folder"  option to "Send to" submenu is not very complicated task:
How to Restore Missing “Compressed (zipped) Folder” Item in Send To Menu in Windows XP, ...
Edit the Windows 7 "Send To" Menu Without Third-Party Tools
KB310270

Next,
all we need to check if "Compressed (zipped) folder"  exists in "Send to" submenu is the list of Send to folder's items . We don't even  have to know the full path to it .
Shell special folder ID for "Send to " = 9 (see here ) ... so we just call
Quote
IDispatch::NameSpace(9)
and get required folder object .

 


dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Number and type of arguments required for call to C library
« Reply #133 on: June 06, 2014, 11:47:58 PM »
Quote
Code: [Select]
IDispatch::NameSpace(9)

that just opens the SendTo target folder   :P

a few interesting ordinals...

Code: [Select]
OLEAUT32.2    SysAllocString
OLEAUT32.8    VariantInit
OLEAUT32.9    VariantClear
OLEAUT32.17   SafeArrayGetDim
OLEAUT32.19   SafeArrayGetUBound
OLEAUT32.20   SafeArrayGetLBound
OLEAUT32.23   SafeArrayAccessData
OLEAUT32.24   SafeArrayUnaccessData
OLEAUT32.184  SystemTimeToVariantTime
OLEAUT32.411  SafeArrayCreateVector

SHELL32.16    ILFindLastID
SHELL32.17    ILRemoveLastID
SHELL32.18    ILClone
SHELL32.25    ILCombine
SHELL32.28    SHILCreateFromPath
SHELL32.67    Shell_MergeMenus
SHELL32.73    SHShellFolderView_Message
SHELL32.155   ILFree
SHELL32.165   SHCreateDirectory
SHELL32.182   ShellMessageBoxW
SHELL32.190   ILCreateFromPathW
SHELL32.256   SHCreateShellFolderView
SHELL32.743   SHCreateFileExtractIconW
SHELL32.744   Create_IEnumUICommand
SHELL32.745   Create_IUIElement

SHLWAPI.16    SHCreateThread
SHLWAPI.107   LoadStringWrapW, wrapper for LoadString
SHLWAPI.199   IUnknown_Set
SHLWAPI.215   SHAnsiToUnicode
SHLWAPI.217   SHUnicodeToAnsi
SHLWAPI.219   QISearch
SHLWAPI.346   SHUnicodeToUnicode
SHLWAPI.354   SHFormatDateTimeW
SHLWAPI.456   PathIsValidCharW
SHLWAPI.485   MapWin32ErrorToSTG

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Number and type of arguments required for call to C library
« Reply #134 on: June 06, 2014, 11:49:14 PM »
hmmmm....

try creating a file with the extension ".ZFSendToTarget" and writing to it