1 00:00:01,130 --> 00:00:05,400 Hello and welcome to the lesson on the APA. 2 00:00:05,480 --> 00:00:16,730 You esteem multiple process, true going down this project, call 15 Dash Multi Process Control and 3 00:00:16,730 --> 00:00:17,360 unzip it. 4 00:00:17,750 --> 00:00:19,730 Put it in the email death to folder. 5 00:00:20,780 --> 00:00:30,050 Also download this file, which contains some useful links and references accompanying this lesson. 6 00:00:32,700 --> 00:00:42,930 Inside this file, this folder, you will see a few files compile that is the script used to build the 7 00:00:42,930 --> 00:00:50,340 multiple access control program we should be using to demonstrate multiple process control. 8 00:00:51,300 --> 00:00:59,370 And there's also the message box binary, which is actually a raw shellcode, as well as the message 9 00:00:59,370 --> 00:01:02,280 box to see which is the. 10 00:01:04,930 --> 00:01:08,770 Cheryl Cook properly formatted for inclusion in sight. 11 00:01:09,580 --> 00:01:11,940 He program. 12 00:01:12,850 --> 00:01:17,020 So this one should be deleted before he can compile this. 13 00:01:17,860 --> 00:01:18,340 So 14 00:01:21,070 --> 00:01:26,230 let me just explain to you first how this moves into a narrow folder. 15 00:01:27,520 --> 00:01:31,800 So let's open the multi process control file. 16 00:01:33,080 --> 00:01:36,620 On the top, you have your message box 64bit Sharkawy. 17 00:01:38,230 --> 00:01:46,150 Yes, you are seeing many times before now this program, when you runs, is just going to allocate 18 00:01:46,150 --> 00:01:47,170 some memory. 19 00:01:49,140 --> 00:01:54,840 And then Capiz Shell going to that memory, and there's a security that's only guess. 20 00:01:55,590 --> 00:01:56,910 So let's take a look. 21 00:01:58,360 --> 00:02:08,020 We declare a handles cohesion lock and also some defines in order to be used if our new function call 22 00:02:08,140 --> 00:02:12,910 is process running, is process running issues in the main function. 23 00:02:13,750 --> 00:02:15,850 Over here you will see that. 24 00:02:17,260 --> 00:02:19,930 We call his process running over here. 25 00:02:21,610 --> 00:02:29,040 There is we check whether the process is already running in memory, if it is, he will then quickly 26 00:02:29,530 --> 00:02:30,550 by returning zero. 27 00:02:31,810 --> 00:02:39,510 Before that, he will print his message to the council to inform the user the new process tonight because 28 00:02:39,520 --> 00:02:41,050 it is already running in memory. 29 00:02:42,910 --> 00:02:48,340 And then over here you see that he allocates memory for the payload. 30 00:02:50,250 --> 00:02:57,990 And then sorry, I don't get memory wearable, and it copies Bill to the allocated memory. 31 00:02:58,800 --> 00:03:06,020 And then over here, it makes the pill executable and readable by using which are protected. 32 00:03:07,050 --> 00:03:09,600 And over here you will then create it check. 33 00:03:10,020 --> 00:03:17,110 That means you will run the court and then you bring the message to the user and then wait for the. 34 00:03:19,140 --> 00:03:25,800 And here, if you close the lock, so this lock is global, it is coming here. 35 00:03:25,840 --> 00:03:33,600 This is very likely and this is a lock that is going to be us in, say, the program throughout the 36 00:03:34,410 --> 00:03:36,030 selection process running. 37 00:03:36,750 --> 00:03:39,150 So let us take a look at how this process is running. 38 00:03:40,090 --> 00:03:46,420 You will find here that there are several implementation of the lock forces to mute mutex lock. 39 00:03:47,410 --> 00:03:48,640 Second is semaphore. 40 00:03:49,830 --> 00:03:59,700 So this event and Toffees named bikes, and we can choose which one to use by specifying the type of 41 00:03:59,700 --> 00:04:03,180 lock here, so that is totally new tax law. 42 00:04:05,020 --> 00:04:13,080 So this changes to tax when you specify the type of lights new tax incentive program. 43 00:04:13,410 --> 00:04:18,900 You will then check if the control method is mutates, you will then create new tax. 44 00:04:19,560 --> 00:04:27,450 He will create new tax law using this API function, which you can read up by going to this link to 45 00:04:28,500 --> 00:04:29,310 create new tax. 46 00:04:30,180 --> 00:04:32,790 So create new tax is a function. 47 00:04:35,430 --> 00:04:39,360 So creating new text can be referred in the media in reference here. 48 00:04:39,930 --> 00:04:41,520 It accepts three parameters. 49 00:04:41,820 --> 00:04:43,600 The most important is the thirty one. 50 00:04:43,640 --> 00:04:43,890 It doesn't. 51 00:04:43,890 --> 00:04:45,570 One is the name of the lok. 52 00:04:46,470 --> 00:04:48,420 So you need to provide a name for a lock. 53 00:04:49,200 --> 00:04:55,560 You could hear the name of a lock at that parameter here called controlling and is defined here. 54 00:04:56,520 --> 00:04:58,290 Control name is global. 55 00:04:58,560 --> 00:05:07,690 My lock If you want to know more about the name of the perimeter, you can read up here and the kernel 56 00:05:07,710 --> 00:05:08,240 objects. 57 00:05:09,360 --> 00:05:16,170 So this article kind of getting these spaces to tell you how to give names for you and for your objects 58 00:05:16,440 --> 00:05:18,330 that you are going to use for the locks. 59 00:05:20,610 --> 00:05:25,680 Then the second time of lock, we can use this call Semaphore symbol for access. 60 00:05:26,130 --> 00:05:28,230 One two three four barometers. 61 00:05:29,210 --> 00:05:32,480 And you can read in the media and reference as well. 62 00:05:34,900 --> 00:05:40,120 Over here, and the most important parameter again is the folk barometer. 63 00:05:40,930 --> 00:05:43,480 So this is an improved version of a new tax lock. 64 00:05:43,870 --> 00:05:52,270 It has got this additional two parameters which can keep count of how many times the critical section 65 00:05:52,270 --> 00:05:53,110 has been accessed. 66 00:05:53,650 --> 00:05:57,250 So critical section is the part of memory which you are controlling. 67 00:05:57,460 --> 00:05:59,950 So it gives count of the minimum and maximum here. 68 00:06:01,270 --> 00:06:04,540 So the barometer is the most important one. 69 00:06:04,930 --> 00:06:12,550 And again, we used these same type of name namespace called truly global malloc. 70 00:06:14,110 --> 00:06:18,130 The third type of lock is called the event a log a. 71 00:06:18,940 --> 00:06:21,190 We use the API create event. 72 00:06:23,610 --> 00:06:29,790 Creative event explain in this Microsoft and the here he has got these parameters. 73 00:06:30,030 --> 00:06:37,620 And again, the most important barometer is the fourth parameter, the name of the event, which again, 74 00:06:37,620 --> 00:06:39,090 we are using control name. 75 00:06:39,930 --> 00:06:47,180 And lastly, the fourth type of lung is called neem pipe, and he uses the API function call create 76 00:06:47,190 --> 00:06:48,000 name by. 77 00:06:50,160 --> 00:06:53,400 This is the standard reference for grading, folks. 78 00:06:53,820 --> 00:07:01,710 He has got a long list of parameters by the most important one is the first parameter named after the 79 00:07:01,710 --> 00:07:04,320 fact that you want to create by name. 80 00:07:04,350 --> 00:07:10,320 So in this case here, the Typekit name be created to be this string here. 81 00:07:10,320 --> 00:07:11,820 Call by my lock. 82 00:07:12,450 --> 00:07:17,520 And this convention is also explained by the Microsoft article. 83 00:07:21,060 --> 00:07:21,690 Over here. 84 00:07:22,940 --> 00:07:25,340 He explains the name of the bike. 85 00:07:25,610 --> 00:07:32,580 The convention of the name to this is what we are using and then we are creating the name here. 86 00:07:34,160 --> 00:07:34,730 So. 87 00:07:36,450 --> 00:07:43,650 This is how the empire works, so if NASA after you have already run this process, once it will go 88 00:07:43,650 --> 00:07:50,730 ahead and create the look and then when the second process try to start again, he is going to check 89 00:07:51,540 --> 00:07:54,810 it is going to check by using his process running. 90 00:07:55,080 --> 00:08:00,720 He would try to create a second look using the same name, and he will fail because he would get the 91 00:08:00,720 --> 00:08:02,610 error over the ACS error. 92 00:08:03,270 --> 00:08:08,820 So once he finds this error, he will then close and return the means the program will kick. 93 00:08:09,510 --> 00:08:11,610 So this is how locks work. 94 00:08:12,030 --> 00:08:19,770 Same thing is semaphore as well if the first process that runs has already already acquired a semaphore 95 00:08:20,190 --> 00:08:20,970 for this name. 96 00:08:21,960 --> 00:08:28,260 The second process cannot again create the same semaphore using the same name, same event as well as 97 00:08:28,460 --> 00:08:28,830 pipes. 98 00:08:29,520 --> 00:08:38,880 So this is how the we are able to control the number of processes that are running in the memory. 99 00:08:39,330 --> 00:08:41,100 So that's all for this video. 100 00:08:41,340 --> 00:08:42,720 Thank you for watching.