1 00:00:00,680 --> 00:00:04,850 Hello and welcome to the political walkthrough on multiprocessor control. 2 00:00:05,480 --> 00:00:07,130 Let's open this project now. 3 00:00:07,610 --> 00:00:09,770 We are going to build it and run it. 4 00:00:11,360 --> 00:00:18,950 So first we copy the path to this project and then we open our activity for native tools command from. 5 00:00:22,670 --> 00:00:27,140 And then we navigate to the folder issue of yes, copy. 6 00:00:30,830 --> 00:00:32,730 And Randy Cohen basket. 7 00:00:38,380 --> 00:00:43,600 Now he has finished compiling building we can run by. 8 00:00:46,170 --> 00:00:52,050 Pressing internal, and you can see that in the shellcode has. 9 00:00:53,100 --> 00:00:55,500 But that message box with a message. 10 00:00:55,740 --> 00:00:58,050 Hello from crack militants dot com. 11 00:00:58,680 --> 00:01:04,230 And you can see there's also output on the terminal showing us the handle to the lock. 12 00:01:04,500 --> 00:01:05,190 64. 13 00:01:05,580 --> 00:01:08,160 And the Trek creator in running. 14 00:01:08,860 --> 00:01:12,930 So just open the source code and try to follow along. 15 00:01:13,110 --> 00:01:14,880 See where it is coming from. 16 00:01:16,700 --> 00:01:21,110 So the first message is sixty four is coming from. 17 00:01:25,820 --> 00:01:26,420 From here. 18 00:01:28,350 --> 00:01:35,580 Sixty four and then the second message trick creator and running is coming from here. 19 00:01:36,610 --> 00:01:37,870 Trade created and rainy. 20 00:01:39,430 --> 00:01:47,050 So now let us try to run the same process again a second time and see whether he succeeds, so we'll 21 00:01:47,050 --> 00:01:53,140 copy the top one more time and open another access before any DevTools command prompt. 22 00:01:54,560 --> 00:02:01,570 Navigate to the same folder and run the same program again. 23 00:02:02,770 --> 00:02:05,950 And you see, he says, new processes. 24 00:02:05,950 --> 00:02:11,140 The night is already running in memory so that it's coming from here. 25 00:02:13,600 --> 00:02:18,430 So when you try to run the process, a second time is trying to create another lock. 26 00:02:21,030 --> 00:02:28,470 So what happens is you come here and you start the program, you will come here, you will again call 27 00:02:28,470 --> 00:02:37,350 this function is process running and pass it in a type of lock that you want to to use in this case, 28 00:02:37,350 --> 00:02:37,950 mutex. 29 00:02:38,730 --> 00:02:47,720 So you come here to the function is process running, and he receives the permit mutex and over here 30 00:02:47,740 --> 00:02:48,180 tests. 31 00:02:48,750 --> 00:02:51,150 So your control method is mutates. 32 00:02:51,390 --> 00:02:52,350 So this is true. 33 00:02:52,830 --> 00:02:59,370 So you would try to create another lock, but by using the same controller name as the first, yeah, 34 00:02:59,400 --> 00:03:00,330 first process. 35 00:03:00,900 --> 00:03:03,390 But he feels there you will get an error. 36 00:03:03,990 --> 00:03:06,900 So the error here is error already exists. 37 00:03:07,260 --> 00:03:11,550 And because of that, you will close a handle, so it will return true. 38 00:03:13,060 --> 00:03:19,600 So the default is is process running should be followed by here because you get the error or the ax. 39 00:03:20,020 --> 00:03:22,180 So this is set to true. 40 00:03:22,690 --> 00:03:27,850 So this true is being written and then he returns to the caller over here. 41 00:03:28,900 --> 00:03:31,330 He returns to the caller over here. 42 00:03:31,810 --> 00:03:32,620 This is true. 43 00:03:33,010 --> 00:03:36,640 So if it's true, he would bring a message process is denied. 44 00:03:36,970 --> 00:03:38,440 It is already running in memory. 45 00:03:38,740 --> 00:03:43,960 And then he will close in a main function by returning zero. 46 00:03:44,590 --> 00:03:46,000 So it's how it works. 47 00:03:46,930 --> 00:03:50,440 So we can also check my writing process had canal. 48 00:03:52,770 --> 00:04:00,360 And you can search you can search for the handle by clicking on this, find Hindu. 49 00:04:01,720 --> 00:04:04,480 And you say here we look for our name. 50 00:04:06,310 --> 00:04:08,470 Have a look, which is here. 51 00:04:08,590 --> 00:04:09,160 My luck. 52 00:04:10,900 --> 00:04:13,840 So here we look for my luck. 53 00:04:16,450 --> 00:04:16,870 Fine. 54 00:04:17,590 --> 00:04:21,430 And you see the tiniest mutant also known as mutex. 55 00:04:22,210 --> 00:04:25,420 And this is the name space for our luck. 56 00:04:26,820 --> 00:04:33,570 So that is why second process feels to run because the logging was already in place. 57 00:04:35,220 --> 00:04:36,640 And that is not true. 58 00:04:37,150 --> 00:04:38,110 The second one. 59 00:04:40,230 --> 00:04:42,930 So we change this to say I'm a foreigner. 60 00:04:48,030 --> 00:04:57,660 Semaphore, as you will recall, Semaphore is the one off the thanks of luck you find here. 61 00:04:59,130 --> 00:05:03,060 So we save our source code and we. 62 00:05:05,360 --> 00:05:13,130 Close this first one, and now we're going to rebuild by Colleen screaming again. 63 00:05:14,900 --> 00:05:17,330 And now running again. 64 00:05:21,200 --> 00:05:24,110 And we try to open another instance. 65 00:05:27,230 --> 00:05:30,890 From another time and again, he feels. 66 00:05:32,040 --> 00:05:34,860 All right, this time now we check the process hacker. 67 00:05:37,220 --> 00:05:42,920 Research for my blog and you find now is the time this has been changed to Semaphore. 68 00:05:45,020 --> 00:05:45,410 All right. 69 00:05:45,440 --> 00:05:46,250 So he's working. 70 00:05:48,070 --> 00:05:55,990 Now that is try the next one, which is the event, so come back down here. 71 00:05:56,260 --> 00:05:58,300 Hey, chief, these two event 72 00:06:01,450 --> 00:06:01,890 safe? 73 00:06:02,110 --> 00:06:02,820 Yeah, cool. 74 00:06:04,690 --> 00:06:07,270 And then recompile. 75 00:06:11,940 --> 00:06:13,230 And then running again. 76 00:06:15,550 --> 00:06:22,710 And now go to the different am known and try to run a second time and again, he feels. 77 00:06:24,230 --> 00:06:35,720 So he is working this two hour namespace, our lock files and click again and this time Typekit event. 78 00:06:36,650 --> 00:06:38,630 So that is what he uses even. 79 00:06:41,160 --> 00:06:47,490 Because we are using this create even API. 80 00:06:49,450 --> 00:06:51,090 They aren't going to use him or create. 81 00:06:51,390 --> 00:06:53,640 Maybe he wanted to create a semaphore lock. 82 00:06:53,640 --> 00:06:55,350 We use create him out for API. 83 00:06:56,250 --> 00:06:58,860 So now we know we're going to try new pipes. 84 00:06:59,580 --> 00:07:08,280 So let us change this to name by name by save it and then. 85 00:07:09,510 --> 00:07:10,890 Close the first program. 86 00:07:11,940 --> 00:07:14,880 Now the rebuilt again. 87 00:07:19,980 --> 00:07:20,940 Then we run it. 88 00:07:22,470 --> 00:07:28,980 It is running now, and we go to our second terminal and we run again. 89 00:07:29,550 --> 00:07:31,680 He tried to move again and he fears again. 90 00:07:32,130 --> 00:07:32,910 So he's walking. 91 00:07:33,600 --> 00:07:39,170 So we go back to our find handles and click on Find I'm. 92 00:07:39,740 --> 00:07:40,850 And this time you find it. 93 00:07:40,980 --> 00:07:47,490 Is this file so named fight with a kind of virtual file, which is in memory? 94 00:07:47,730 --> 00:07:48,120 It is. 95 00:07:48,120 --> 00:07:56,640 Purpose is to do in the process communication, but you are using it in this example as kind of lock. 96 00:07:57,480 --> 00:08:08,150 So this is the how we can control how a number of processes running memory by using this lock. 97 00:08:09,630 --> 00:08:11,220 So that's all for this session. 98 00:08:11,610 --> 00:08:13,500 Thank you for watching.