Jump to content

StgCreateStorageEx example


Recommended Posts

Does someone worked with Stg* functions to extract embedded file from ole streams? I want to call StgCreateStorageEx but any time it fails. I would appreciate any good direction to work with those functions.

This is what I tried but I get STG_E_INVALIDFLAG erorr.

#include <WinAPI.au3>
#include <Array.au3>

Global Const $STGM_READ = 0x00000000
Global Const $STGM_SHARE_EXCLUSIVE = 0x00000010
Global Const $STGM_CREATE = 0x00001000
Global Const $STGFMT_ANY = 4


Local $tObject = DllStructCreate("ptr")
$avCall = DllCall("ole32.dll","long","StgCreateStorageEx","wstr","ole.bin","dword",$STGM_READ,"dword",$STGFMT_ANY,"dword",0,"ptr",Null,"ptr",Null,"struct*",_WinAPI_GUIDFromString('{0000000B-0000-0000-C000-000000000046}'),"ptr",DllStructGetPtr($tObject))
If $avCall[0] <> 0 Then ConsoleWrite(Hex($avCall[0]) & @CRLF)

ole.zip

Edited by Andreik
Link to comment
Share on other sites

In the remarks for StgCreateStorageEx you can read the following: "This function cannot be used to open an existing file; use the StgOpenStorageEx function instead."

If you use these values

Global Const $STGM_READ = 0x00001000+0x00000010+0x00000002
Global Const $STGFMT_ANY = 0
your code will create a new ole.bin (remove an existing file before you run the code).
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...