flat assembler
Message board for the users of flat assembler.
Index
> Windows > api for autosync memory block among several processes |
Author |
|
LostCoder 12 Jul 2012, 18:47
You can try network file sharing with MapViewOfFile, however I'm not sure that MapViewOfFile will work with shared files.
|
|||
12 Jul 2012, 18:47 |
|
typedef 12 Jul 2012, 22:19
Just go with Winsock or Wininet (ftp, use APIs like InternetOpenFile, InternetSetFilePointer, InternetReadFile)
Make the server run on FTP with just simple commands like STAT,LIST,GET. |
|||
12 Jul 2012, 22:19 |
|
f0dder 22 Jul 2012, 00:24
There's no built-in API to do this, and it's a somewhat complex task to do if you want to do it right (i.e., a robust implementation that's also fast and scales well).
Memory mapped files are not the way to go, at least not without an additional layer on top - quoting MSDN: Quote: With one important exception, file views derived from any file mapping object that is backed by the same file are coherent or identical at a specific time. Coherency is guaranteed for views within a process and for views that are mapped by different processes. |
|||
22 Jul 2012, 00:24 |
|
sleepsleep 25 Jul 2012, 15:35
i was thinking something like below, would it be something breakthrough?
eg, a http webserver that more like asm scripting engine. where the "programming" is done through compiled language, and the webserver call user proc via dll. like a bridge for web application into windows api m1 = memory place name http://localhost/memalloc,1024,m1 reply ok http://localhost/memput,m1,0,857 reply ok // we put 857 in memory space [0] user1 = http://localhost/memrun,adding,[0],3 reply 860 user2 = http://localhost/memrun,adding,[0],4 reply 861 http://localhost/memrun,adding,5,10 reply 15 http://localhost/memput,m1,5,this is a quick brown fox proc adding a b mov eax, dowrd [a] add eax, dword [b] endp |
|||
25 Jul 2012, 15:35 |
|
revolution 25 Jul 2012, 15:41
This doesn't appear to be any sort of "breakthrough" as you put it. It is just like the standard DB access that every DB engine offers.
BTW: It is also really really slow. |
|||
25 Jul 2012, 15:41 |
|
hopcode 25 Jul 2012, 15:42
sleepsleep wrote: a http webserver that more like asm scripting engine fasm compiler online with feedback on local procs something using RPC (remote procedure call) and revisiting the protocol if necessary. Cheers, _________________ ⠓⠕⠏⠉⠕⠙⠑ |
|||
25 Jul 2012, 15:42 |
|
sleepsleep 25 Jul 2012, 22:10
revolution wrote:
thanks, as you said, it could be really slow, and tons of security problems, i will try brainstorm more later. hopcode wrote:
thanks too |
|||
25 Jul 2012, 22:10 |
|
f0dder 26 Jul 2012, 13:49
sleepsleep: if you go the HTTP way, read up on the REST principles - you don't want to GET a 'memalloc' resource, you want to PUT or POST a 'memory' resource...
But as revolution wrote, HTTP is probably too much overhead for a shared memory protocol... especially if you need security, because you really need SSL then. |
|||
26 Jul 2012, 13:49 |
|
r22 26 Jul 2012, 18:52
Google's RESTful gdata api and Microsoft's WebDAV work fairly well with regards to security and efficiency. If by overhead you were criticizing the time it would take to fully implement in ASM then I'd agree, implementing a fully functional HTTP(S) server in ASM would be substantial overhead.
The original query doesn't really mention any security constraints. A simple TCP/IP Server/Client with the main file memory mapped on the server and temporary files memory mapped on each client would likely be the easiest most efficient solution. The server code would be as follows (pseudo code) Code: // server main loop WHILE Server_Is_Running FOR EACH Client IN Connected_Clients // did the client send a READ/WRITE command? Read = recv (Client, Cmd_Buffer, CMD_SIZE) IF Read == CMD_SIZE THEN IF Cmd_Buffer == CMD_READ THEN // get the parameters (offset) and (size) Read0 = recv (Client, Param_Offset_Buffer, PARAM_SIZE) Read1 = recv (Client, Param_Size_Buffer, PARAM_SIZE) IF Read0 == PARAM_SIZE && Read1 == PARAM_SIZE THEN // give the client the requested portion of memory send (Client, Cmd_Buffer, CMD_SIZE) send (Client, Param_Offset_Buffer, PARAM_SIZE) send (Client, Param_Size_Buffer, PARAM_SIZE) send (Client, Mapped_File_View_Ptr + Param_Offset_Buffer, Param_Size_Buffer) END IF ELSE IF Cmd_Buffer == CMD_WRITE THEN // get the parameters (offset) and (size) Read0 = recv (Client, Param_Offset_Buffer, PARAM_SIZE) Read1 = recv (Client, Param_Size_Buffer, PARAM_SIZE) IF Read0 == PARAM_SIZE && Read1 == PARAM_SIZE THEN // get the parameter (data) to write Read = recv (Client, Data_Buffer, Param_Size_Buffer) IF Read == Param_Size_Buffer THEN // update the memory CopyMemory (Mapped_File_view_Ptr + Param_Offset_Buffer, Data_Buffer, Param_Size_Buffer) // Tell all clients of the updated portion of the memory FOR EACH c IN Connected_Clients send (c, Cmd_Buffer, CMD_SIZE) send (c, Param_Offset_Buffer, PARAM_SIZE) send (c, Param_Size_Buffer, PARAM_SIZE) // choose whether you want clients to receive updated data automatically // or if they should just be notified and have to request the data send (c, Data_Buffer, Param_Size_Buffer) END FOR END IF END IF END IF END IF END FOR END WHILE In the above case the server is processing synchronously to simply the pseudo code. The simple protocol is fairly easy to implement. Code: {Read|Write}{Offset}{Size}{Data} You could optimize the protocol further by just having Code: {Offset} {Size|-Size} {Data} Where the -negative size would denote a Write. Or use a separate tcp port for Read and Write requests. Or a command and data tcp port. Anyways, there are infinitely many ways to program the skinning of a cat. |
|||
26 Jul 2012, 18:52 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.