Windows API Memory Mapped Files Explained

Поділитися
Вставка
  • Опубліковано 14 лют 2024
  • In this video I will demonstrate how memory mapped files can be used to share memory between processes by making a simple local chat example
    Code: gist.github.com/nir9/7f61b01c...
  • Наука та технологія

КОМЕНТАРІ • 30

  • @theoriginalneckbeard
    @theoriginalneckbeard 3 місяці тому +8

    Hey, Nir.
    I wanted to thank you, simply because you're my favorite programming related channel right now and make me having hope in serious, high quality and non click-bait-y content on UA-cam again.
    Its informational and educational, quality over quantity and I appreciate exactly this in these days and times, where most channels point their focus on generating the most possible traffic through being striking and superficial.

    • @nirlichtman
      @nirlichtman  3 місяці тому +1

      Thanks, I appreciate this :)

  • @minnoxzmozzesmx8915
    @minnoxzmozzesmx8915 3 місяці тому +2

    I've known mmap for a long time, but not understand the practical use of it. Thanks for the tutorial.

    • @itsdrdy5551
      @itsdrdy5551 3 місяці тому

      mmap in windows is VirtualAlloc, not a mapped file

  • @jorgerias262
    @jorgerias262 3 місяці тому

    Thanks, currently learning this in my OS class, but it's super insightful and useful to see someone program it.

  • @ISAK.M
    @ISAK.M 2 місяці тому

    This was so well explained thank u man

  • @harunsarpnar3428
    @harunsarpnar3428 3 місяці тому +3

    high quality content congrats👏👏

  • @oracleoftroy
    @oracleoftroy 3 місяці тому +3

    This seems like it has some pretty serious race conditions. Without knowing exactly what the guarantees for the shared condition variable are in windows off the top of my head, I think you would want to not autoreset so that the file won't be written to while you are reading it, and only reset once the read is finished. And you probably want to make sure it is false before the server writes new data,.. assuming we want every write to be followed by a read. (Something else would need to be done otherwise.)
    Still, pretty neat seeing how easy it is to set this up. I haven't needed something quite like this before and didnt realize that it doesn't take much code ro get it working.

  • @3bdo3id
    @3bdo3id 2 місяці тому

    Great work, I loved it

  • @angelffg
    @angelffg 3 місяці тому

    Excellent video!
    Nir, does this apply to applications between 2 or more computers on an internal network or does it only work for communication between programs on the same computer?
    Thanks for supporting!

    • @nirlichtman
      @nirlichtman  3 місяці тому +2

      Thanks! It only works for communication between programs on the same computer, I mostly used this example to demonstrate basic usage of memory mapped files

    • @angelffg
      @angelffg 3 місяці тому

      @@nirlichtman Thanks Nir, excellent content!

  • @Pipe0481
    @Pipe0481 3 місяці тому +2

    I'd love to see the Linux equivalent of this

    • @ryonagana
      @ryonagana 3 місяці тому

      on linux. pipe/socket is the only way

    • @dimi144
      @dimi144 3 місяці тому

      mmap has an fd parameter that lets you map a file into memory

  • @rian0xFFF
    @rian0xFFF 3 місяці тому +21

    Next video: Making a simple GPT-4 AI in C on Windows

    • @nirlichtman
      @nirlichtman  3 місяці тому +16

      😂 "Minimalist" AI

    • @holiamusic
      @holiamusic 3 місяці тому +1

      xD@@nirlichtman

    • @ngokhanh7291
      @ngokhanh7291 3 місяці тому +2

      AI that predicts the age based on an input age

  • @justinnamilee
    @justinnamilee 3 місяці тому

    NIce.

  • @maartenofbelgium
    @maartenofbelgium 3 місяці тому

    Love the simplicity!

  • @thisisnotok2100
    @thisisnotok2100 3 місяці тому

    Very cool. I've had an interest in how vpn clients "hijack" traffic to encrypt and reroute it to the the VPN server. Could you do a simple demonstration of an application that does something like this?

    • @nirlichtman
      @nirlichtman  3 місяці тому

      Thanks! Could you give an example about this? I am pretty sure the VPN clients just work by changing the network settings on the computer and set up the traffic to go through the VPN server

  • @GooogleGoglee
    @GooogleGoglee 3 місяці тому

    Very high quality, I think I have got lost 😅
    Why not using 'nc' ?

    • @nirlichtman
      @nirlichtman  3 місяці тому +1

      The idea is to demonstrate how to work with shared memory on Windows

    • @GooogleGoglee
      @GooogleGoglee 3 місяці тому

      @@nirlichtman it was very neat 👍🏻

  • @EnLopXf
    @EnLopXf 3 місяці тому

    Please make another tutorials about WinAPI

    • @nirlichtman
      @nirlichtman  3 місяці тому +1

      More Win32 vids are planned :)

  • @kheirou1990
    @kheirou1990 3 місяці тому

    More assembly please

    • @nirlichtman
      @nirlichtman  3 місяці тому +1

      More Assembly planned :)