Prerequisites: Flash must be encrypted and cannot leave files on the hard disk. Start point: The properties of the Flash player accept the local file name or HTTP URL. First of all, of course, it is looking for a solution on the web. After looking for a long time, I found a domestic, one foreign. Are sold. Surprisingly, they did not have to use Delphi. According to people understand, it uses a unapproved attribute Moviedata, which uses Flash, which is not recorded, but it should be seen from the name that should be acceptable. Its domestic version currently does not support the latest Flash player. This is not a bit worry. So try to come as much as possible. Idea: The most beginning is to build an agreement (similar to RTSP sample) to replace HTTP and transfer the request to the local daemon. Later, I didn't think it's better to create a simple HTTP server directly, using the HTTP URL directly, so it is definitely feasible, so I wrote the HTTP server. Write a simple test program, listening to some HTTP packages, finding that even if a simple HTTP server is built, you also need to understand the RFC2612, taking into account the response and labels of the Flash different versions, the response head is quite complicated. When I see RFC2612, I suddenly thought that the establishment HTTP server is a virtual a URL; if it is possible to virtualize a local file name, is it simpler? According to this idea, I found a small time, of course, a lot of detours. Finally, it can be processed with a pipe. Because the pipeline client is also handled by CreateFile, readfile, as a normal file. This will use the pipe name to replace the file name to deceive Flash music ^ _ ^ When the fraudulent Flash read file: CreateFile, Readfile is actually reading the pipeline, just he doesn't know. And we can Does the pipe write anything, does this not achieve the purpose? The section code was verified, it is really feasible. Moreover, the stream environment of the network is also simulated (10 bytes per time, delayed 3MS), and the effect is good, just as expected. The following code to the code is the test program, which is more zero. If you look at the above content carefully, and if you are not unconneated, you should don't have to look at the following code. Attach is just to make a memo. The code is a Console program, the VS2003 environment. Assume that there is a sample flash is blue.swf. The set pipe name is: //./pipe/EGBPIPE verification, run this program, and ensure that Blue.swf exists. Then open the flash player and use her play file "//pipe/EGBPIPE". Code start: ------------- // pipeService.cpp: Defines the entry point of the console application. //
#include "stdafx.h"
#define buffsize 1024 # Define Pipe_timeout 1000
INT __MAIN (VOID); int myerrexit (char *); int _tmain (int Argc, _tchar * argv []) {__main (); return 0;}
#include
//pipe/egbpipe
* /
int __main (void) {BOOL fConnected; DWORD dwThreadId; HANDLE hPipe, hThread; LPTSTR lpszPipename = ".//pipe//egbpipe"; // The main loop creates an instance of the named pipe and // then waits for a client to connect to it. When the client // connects, a thread is created to handle communications // with that client, and the loop is repeated. for (;;) {hPipe = CreateNamedPipe (lpszPipename, // pipe name PIPE_ACCESS_DUPLEX, / / read / write access PIPE_TYPE_MESSAGE | // message type pipe PIPE_READMODE_MESSAGE |. // message-read mode PIPE_WAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // max instances BUFSIZE, // output buffer size BUFSIZE, // input buffer size PIPE_TIMEOUT, / / client time-out null; // no security attribute
if (hPipe == INVALID_HANDLE_VALUE) MyErrExit ( "CreatePipe"); // Wait for the client to connect; if it succeeds, // the function returns a nonzero value If the function returns // zero, GetLastError returns ERROR_PIPE_CONNECTED fConnected =.. ConnectNamedPipe (hPipe, NULL) TRUE:?. (GetLastError () == ERROR_PIPE_CONNECTED); if (fConnected) {// Create a thread for this client hThread = CreateThread (NULL, // no security attribute 0, // default stack size (LPTHREAD_START_ROUTINE) InstanceThread, (LPVOID) hPipe, // thread parameter 0, // not suspended & dwThreadId); // returns thread IDif (hThread == NULL) MyErrExit ( "CreateThread"); else CloseHandle (hThread);} else / / The Client Could Not Connect, So Close The Pipe. CloseHandle (HPIPE); } Return 1;} VOID InstanceThread (LPVOID lpvParam) {CHAR chRequest [BUFSIZE]; CHAR chReply [BUFSIZE]; DWORD cbBytesRead, cbReplyBytes, cbWritten; BOOL fSuccess; HANDLE hPipe; // The thread's parameter is a handle to a pipe instance. HPIPE = (handle) lpvparam; // while (1) {// read client requests from the pipe. / * fsuccess = readfile (hpipe, // handle to pie, chrequest, // buffer to receive data bufsize, // size of Buffer & CbbytesRead, // Number of Bytes Read Null; // NOT OVERLAPPED I / O
if (! fSuccess || cbBytesRead == 0) break; * / // GetAnswerToRequest (chRequest, chReply, & cbReplyBytes); GetAnswerToRequest (hPipe);. / * // Write the reply to the pipe fSuccess = WriteFile (hPipe, // handle to pipe chReply, // buffer to write from cbReplyBytes, // number of bytes to write & cbWritten, // number of bytes written NULL); // not overlapped I / O // if (fSuccess || cbReplyBytes = cbWritten!! ) break; * /} // Flush the pipe to allow the client to read the pipe's contents // before disconnecting Then disconnect the pipe, and close the // handle to this pipe instance FlushFileBuffers (hPipe);.. DisconnectNamedPipe (hPipe) CloseHandle (HPIPE);
Int myerrexit (char * szinfo) {Return MessageBox (0, Szinfo, "WHOO", MB_OK);
Void getanswertorequest (Handle Hfile) {const Int bufflen = 10; BYTE BUFF [Bufflen] = {0};
FILE * f = fopen ("blue.swf", "rb");
INT Ilen = Bufflen; While (Ilen == Bufflen) {Ilen = FREAD (BUFF, SIZEOF (BYTE), BUFFLEN, F);
Sleep (3); dword ulen = 0; Writefile (Hfile, Buff, Ilen, & Ulen, null);} _fcloseall ();}