virtualbox – How to create virtual file in Delphi app – Education Career Blog

I had a previous post on how to make memorystream play in wmp activex and got a reply with a link to boxedapp sdk. It’s not a freeware so I studied the process and I figured out that it is using a virtual file for the stream to be saved and that its filename is used as the URL. So, my question is how to create a virtual file that returns a handle which should be then be accessed by a THandleStream. I am using Delphi 7. Thanks.

Desired Process on how to make memorystream play in wmp activex or any player:

  1. Create a virtual file and return a HANDLE; (This is my question)
  2. This HANDLE is then accessed by a THandleStream;
  3. THandleStream copies the content of the MemoryStream to be played;
  4. The player(wmp activex in my case) accesses the filename.
  5. The player plays it.

,

If you’re trying to create content that’s hidden from the user, as implied in one of your comments, you may as well forget all about it right now. It’s impossible. Never has worked and never will. You can make it more difficult, but at the end of the day if the computer is able to read it, a clever enough hacker can read your code and duplicate your tricks. Even strongly-encrypted DRM schemes only tend to last about a month at best before being broken, and you’re not even trying to go that far.

,

Boxedapp intercepts all IO calls and in if the file was create using their API (I.E. BoxedAppSDK_CreateVirtualFile) they will handle the call them self. Its not an easy task, you can take a look at detours which is an intercepation framework, but as for intercepting all the IO calls good luck with that.

Why do you need that? why can’t you save the memory stream into the temp folder and play the file from there? do you need to clean the file upon completion?

,

I believe you use the pipe function (from msvcrt.dll):

function _pipe(phandles : pointer; psize : uint; textmode : integer) : integer; cdecl; external 'msvcrt.dll' name '_pipe';

some pseudocode:

var
 _handles : array0..1 of THandle;
begin
  if _pipe(@_handles, size, 0) = -1 then
   Exit;

  FReadHandle := _handles0;
  FWriteHandle  := _handles1;

  _write(FVirtualWriteHandle, Buffer, size);

  close(FWriteHandle);
  close(FReadHandle);

end;

Leave a Comment