1 00:00:00,180 --> 00:00:08,160 So in this video, we'll be seeing how to add the section to the P file so you can add another section 2 00:00:08,160 --> 00:00:09,930 and you need to modify some other fields. 3 00:00:09,930 --> 00:00:14,850 And those fields are the number of sections count in the file header. 4 00:00:14,850 --> 00:00:19,020 You need to increment this one and the size of image. 5 00:00:19,020 --> 00:00:26,040 So the image size increase this and how to calculate this is the last sections virtual address plus 6 00:00:26,040 --> 00:00:26,940 virtual size. 7 00:00:26,940 --> 00:00:31,200 This gives the image size and the size of headers. 8 00:00:31,200 --> 00:00:38,880 So we have the header size you need to increase by one image, a section header. 9 00:00:42,430 --> 00:00:48,430 Well, I think these three and finally, we're going to paste that section here after this. 10 00:00:50,250 --> 00:00:51,570 This section. 11 00:00:52,560 --> 00:00:54,540 So let's get started. 12 00:00:55,410 --> 00:01:01,560 I have already written these add section 60 for the data and they are working fine. 13 00:01:01,830 --> 00:01:03,830 So let's do this again. 14 00:01:03,840 --> 00:01:07,530 So I have corrected the file alignment. 15 00:01:07,530 --> 00:01:19,200 So the file alignment tells us at which multiple of this one does actually start. 16 00:01:19,200 --> 00:01:22,290 So here we have five alignment 200. 17 00:01:22,530 --> 00:01:31,410 So if, if there is a section at the starting of 400 and the section only occupied 100 hexadecimal bytes, 18 00:01:31,410 --> 00:01:41,010 then the next section should not start at 500, it should start at 600 because this should be the section 19 00:01:41,010 --> 00:01:43,160 starting should be multiple of this one file. 20 00:01:45,330 --> 00:01:49,500 So that's why I had featured the file alignment. 21 00:01:49,500 --> 00:01:51,450 So the function takes two parameters. 22 00:01:51,450 --> 00:01:56,100 One is the P file, and the second one is the shared code. 23 00:01:56,430 --> 00:02:00,870 So if you look at the P file in Excel, the hex editor. 24 00:02:01,960 --> 00:02:11,200 You can see the last one is section is obviously not allowed so you can open calculator one zero. 25 00:02:14,370 --> 00:02:19,230 One year, one year zero zero divided by 200 gives you. 26 00:02:23,500 --> 00:02:27,220 This calculator does not use or shows the reminder. 27 00:02:27,220 --> 00:02:33,840 So this one is the best one year zero zero divided by 200. 28 00:02:33,850 --> 00:02:37,240 So if you calculate this one, you get a reminder zero. 29 00:02:37,330 --> 00:02:39,620 So that means we are good to go. 30 00:02:39,640 --> 00:02:42,610 Sometimes you will have some extra bites here. 31 00:02:43,240 --> 00:02:46,510 In that case, what you need to do is you need to. 32 00:02:49,460 --> 00:02:54,050 First let's calculate the P file length. 33 00:02:55,310 --> 00:03:00,350 So this gives me the whole size of the rap file. 34 00:03:06,470 --> 00:03:11,000 So it should be divided with the file alignment. 35 00:03:11,480 --> 00:03:14,690 So one year zero zero is divided by 200. 36 00:03:17,240 --> 00:03:19,630 Which gives me the quotient. 37 00:03:21,370 --> 00:03:23,230 So the quotient is. 38 00:03:26,850 --> 00:03:30,900 In this case, it's a D and the reminder is zero. 39 00:03:41,420 --> 00:03:48,770 So what we're going to do is if, suppose, assume that there are extra some ten bytes, then what you 40 00:03:48,770 --> 00:04:01,100 need to do is you need to skip this from one year 002 plus 200, which gives you 100. 41 00:04:01,100 --> 00:04:08,690 So you need to start the section at that offset because there are ten bytes and you cannot continue 42 00:04:09,380 --> 00:04:12,350 at one year or something. 43 00:04:12,350 --> 00:04:14,270 So you need to add 200 for this. 44 00:04:14,840 --> 00:04:16,670 So what we can do is. 45 00:04:34,410 --> 00:04:41,280 So let's, uh, let's just assume for now, uh, 100. 46 00:04:41,310 --> 00:04:48,570 There are already null bytes has been added to the section so that we can directly add these bites. 47 00:04:48,570 --> 00:04:51,870 So at the end of this video, we are will be fixing this one. 48 00:04:51,870 --> 00:04:52,940 So let's, uh. 49 00:04:55,180 --> 00:04:56,250 B five dot. 50 00:04:58,530 --> 00:04:59,690 By file airline. 51 00:05:03,150 --> 00:05:05,340 And we need to add a plus one to this one. 52 00:05:10,640 --> 00:05:13,100 And we need to multiply with this file line. 53 00:05:13,490 --> 00:05:14,270 So. 54 00:05:16,790 --> 00:05:25,760 So the question will be the 202 de plus one, that is, you get this 1300. 55 00:05:27,200 --> 00:05:35,410 So let's say 202 into E, so which gives us one zero. 56 00:05:35,540 --> 00:05:36,350 So perfect. 57 00:05:36,350 --> 00:05:38,240 So this. 58 00:05:42,090 --> 00:05:44,280 This is going to give us the. 59 00:05:46,970 --> 00:05:47,510 How? 60 00:05:49,230 --> 00:05:52,380 The total size after the section was added. 61 00:05:55,030 --> 00:05:58,360 So that's got this new section size. 62 00:05:58,840 --> 00:06:03,850 New section sizes, this one and this category total size is equal to. 63 00:06:07,320 --> 00:06:13,130 Total size p length and we need to add that new section size. 64 00:06:49,420 --> 00:06:50,680 So let's run this. 65 00:07:02,910 --> 00:07:08,250 So I think the new section says we will have the 1600. 66 00:07:08,260 --> 00:07:09,050 So it's. 67 00:07:10,810 --> 00:07:11,140 Okay. 68 00:07:11,140 --> 00:07:18,760 So we have added one year zero zero and 100 so that we can remove this one in section size. 69 00:07:26,520 --> 00:07:29,790 So we can see the total size is 100. 70 00:07:36,500 --> 00:07:37,250 And. 71 00:07:41,670 --> 00:07:42,480 Sorry for this. 72 00:07:42,510 --> 00:07:44,160 We need to add the share code. 73 00:07:46,200 --> 00:07:49,160 Yes, share code run by file align. 74 00:07:49,170 --> 00:07:52,890 So both will be, I think, similar. 75 00:07:54,300 --> 00:08:01,020 So the new section size is 200 and we can add this P file length. 76 00:08:01,710 --> 00:08:07,680 So in the previous case, what we have done is we have calculated the new total section from this one. 77 00:08:08,160 --> 00:08:16,320 But here we are taking the shared code length, which is some 100 bytes and we are dividing with this 78 00:08:16,320 --> 00:08:16,940 file aligned. 79 00:08:16,950 --> 00:08:23,110 So you get some quotient and you add plus one to this and multiply with five again. 80 00:08:23,940 --> 00:08:26,190 So you get the new section size. 81 00:08:28,210 --> 00:08:30,430 So we got the total size. 82 00:08:33,560 --> 00:08:33,830 One. 83 00:08:33,890 --> 00:08:37,110 See how much we want to get so we can say. 84 00:08:39,310 --> 00:08:40,420 What your Iraq. 85 00:08:48,040 --> 00:08:49,540 Tortorella says. 86 00:09:08,060 --> 00:09:09,650 And the production time should be. 87 00:09:12,540 --> 00:09:13,650 They reiterate. 88 00:09:18,150 --> 00:09:20,160 So we have allocated the size. 89 00:09:24,540 --> 00:09:27,390 And at last, we need to free this one. 90 00:09:27,780 --> 00:09:28,290 Mature. 91 00:09:28,290 --> 00:09:28,830 Free. 92 00:09:45,740 --> 00:09:49,600 So you can specify zero for the size and we can say memory is. 93 00:10:00,600 --> 00:10:02,700 Let's also print the best address. 94 00:10:28,560 --> 00:10:36,390 So now at this point, we can copy the first copy the P file. 95 00:10:41,950 --> 00:10:43,360 Be filed at length. 96 00:10:43,780 --> 00:10:50,230 So this should copy the AP file and then we need to copy the. 97 00:10:52,310 --> 00:10:52,700 Four. 98 00:10:53,030 --> 00:10:57,740 Serco, Serco zero and based address press. 99 00:10:59,190 --> 00:11:00,290 Be forgotten. 100 00:11:03,320 --> 00:11:05,570 And the rent or rent? 101 00:11:07,760 --> 00:11:10,940 So let's put a breakpoint here and let's run this. 102 00:11:22,340 --> 00:11:29,210 And if I go and step this one, I should see the p file here and we can see the p file has been copied. 103 00:11:36,080 --> 00:11:40,150 So if I go and next step into this, I should see the share code. 104 00:11:48,810 --> 00:11:50,880 There is my share called. 105 00:11:55,930 --> 00:12:01,450 So here, this is my grocery cart that you can see 100. 106 00:12:01,480 --> 00:12:06,040 You can see at the one ending of one, we have the circle. 107 00:12:08,440 --> 00:12:10,330 So I think we are good to go now. 108 00:12:12,570 --> 00:12:15,000 So he has successfully copied them. 109 00:12:18,560 --> 00:12:22,010 The file and the section are shared according to the. 110 00:12:24,170 --> 00:12:31,610 So what you need to do is we need to modify this one, these members. 111 00:12:31,610 --> 00:12:32,510 So. 112 00:12:37,090 --> 00:12:40,820 Well, let's go ahead and pass these headers. 113 00:12:45,690 --> 00:12:46,710 Mitch. 114 00:12:48,910 --> 00:12:57,190 Darth Vader instead does not share the pointer to structure. 115 00:13:00,640 --> 00:13:02,110 But his address. 116 00:13:03,790 --> 00:13:05,710 Type of dust header. 117 00:13:06,190 --> 00:13:06,880 So. 118 00:13:09,560 --> 00:13:15,950 Are we getting the door at that venue so we can get the P offset? 119 00:13:17,850 --> 00:13:21,690 And the next one is let's create a new entity, Hitler, 64. 120 00:13:26,240 --> 00:13:29,370 And he had a signature. 121 00:13:29,490 --> 00:13:32,910 So the first four bytes of he header is the signature. 122 00:13:33,630 --> 00:13:44,160 So martial art pointer to structure and the pointer is based address press or dos header dot e or the 123 00:13:44,160 --> 00:13:48,780 venue and the type of, uh. 124 00:13:52,250 --> 00:13:52,720 I'll you. 125 00:13:53,190 --> 00:13:53,820 So. 126 00:13:55,110 --> 00:13:57,300 So it's not a structure. 127 00:13:57,300 --> 00:13:58,710 It's just for bytes. 128 00:13:59,400 --> 00:14:06,840 So we can say martial art reading 32 base address press. 129 00:14:07,940 --> 00:14:13,910 Does either dot e the venue, so they should do fine. 130 00:14:27,410 --> 00:14:28,910 Now we are good to go. 131 00:14:28,940 --> 00:14:40,440 We have the signature and then we can send dot file header equals to marshall dot pointer to structure 132 00:14:41,000 --> 00:14:42,260 based address. 133 00:14:45,420 --> 00:14:48,660 Best address press dos. 134 00:14:54,880 --> 00:15:04,390 Press does header dot l have a new plus form because the signature is four bytes and the type of. 135 00:15:08,180 --> 00:15:15,110 Randy had a 64 so we are good to go now until the 64 so. 136 00:15:30,650 --> 00:15:31,280 Oh, sorry. 137 00:15:31,280 --> 00:15:31,580 Sorry. 138 00:15:31,730 --> 00:15:32,240 It's fine. 139 00:15:32,690 --> 00:15:34,070 So for goodness. 140 00:15:36,090 --> 00:15:37,260 If I had so. 141 00:15:44,680 --> 00:15:48,040 Now we need to pass this optional. 142 00:15:51,440 --> 00:15:53,540 Monitor naught pointer to such. 143 00:15:54,500 --> 00:16:00,860 So this is going to be somewhere big because we need to get starting from base entrance press does header 144 00:16:01,160 --> 00:16:03,020 dot e venue. 145 00:16:03,940 --> 00:16:04,930 Press for. 146 00:16:04,960 --> 00:16:05,740 Press. 147 00:16:05,740 --> 00:16:08,190 So the size of file header is 20 wide. 148 00:16:08,200 --> 00:16:13,990 So I can just say 20 bytes or you can say masher the size of this integrated file. 149 00:16:14,230 --> 00:16:14,680 So. 150 00:16:35,280 --> 00:16:36,180 So I think 151 00:16:38,880 --> 00:16:40,230 everything is personal. 152 00:16:40,260 --> 00:16:46,590 Let's just go and print this one and 3.5. number of sections. 153 00:16:51,890 --> 00:16:54,020 We should see the output as three. 154 00:17:00,860 --> 00:17:03,110 So here we can see the number of sections are three. 155 00:17:03,110 --> 00:17:07,340 So let's also pass these sections. 156 00:17:09,500 --> 00:17:12,320 Image section header. 157 00:17:13,370 --> 00:17:24,380 All the sections is equal to new sections of how many sections are there and header dot option of five 158 00:17:24,440 --> 00:17:26,960 header dot number of sections. 159 00:17:31,850 --> 00:17:34,250 So let's go and root for this. 160 00:17:34,250 --> 00:17:35,960 I guess, then. 161 00:17:55,190 --> 00:17:56,630 So we can say. 162 00:18:01,510 --> 00:18:03,850 This address plus 163 00:18:05,920 --> 00:18:07,780 does better. 164 00:18:09,330 --> 00:18:12,450 So this gives me the P offset. 165 00:18:12,450 --> 00:18:24,390 So now what I can say is my shirt size is off and so this gives me directly the offset to the anti header. 166 00:18:24,390 --> 00:18:26,910 And after anti header we will have sections. 167 00:18:45,910 --> 00:18:47,110 At this point. 168 00:18:50,220 --> 00:18:52,870 You can see all the sections of I. 169 00:18:54,930 --> 00:18:55,710 Calls to. 170 00:19:00,380 --> 00:19:11,390 So we are passing this section of after passing one section header, you need to jump skip that, that 171 00:19:12,380 --> 00:19:13,730 length of the first section. 172 00:19:13,730 --> 00:19:19,520 So how you're going to do is we can say plus. 173 00:19:21,210 --> 00:19:22,470 Are you into? 174 00:19:23,490 --> 00:19:25,730 Martial arts is off. 175 00:19:28,090 --> 00:19:30,780 A pulse section had a. 176 00:19:33,770 --> 00:19:39,040 So what this use is for every iteration, I'm going to fast. 177 00:19:39,080 --> 00:19:41,050 For the first iteration I use zero. 178 00:19:41,060 --> 00:19:47,150 So I'll be getting the exact offset to the first section header for a equals equal to one. 179 00:19:47,150 --> 00:19:49,850 I'm getting the offset to the first section header. 180 00:19:49,850 --> 00:19:55,790 I'm adding again the size of this section header, which gives me the offset to the second section header. 181 00:19:55,970 --> 00:20:04,100 So in that way I'm going to loop all over this one are all the sections now I can say all sections of 182 00:20:04,190 --> 00:20:09,860 my dot name, so we can say a new string. 183 00:20:12,110 --> 00:20:14,180 And if we go ahead and run this. 184 00:20:29,000 --> 00:20:30,110 So let's run this. 185 00:20:30,110 --> 00:20:36,800 And here we can see we got all the sections so we are good to go now. 186 00:20:37,730 --> 00:20:44,540 So we have parser everything, the sections and all we need to do is we going to update these values. 187 00:20:44,540 --> 00:20:46,710 So the first one is sections comp. 188 00:20:49,670 --> 00:20:52,340 Updating sections count. 189 00:20:54,440 --> 00:21:01,340 So we need to find the offset of this section's count so that we can update in the byte area. 190 00:21:04,610 --> 00:21:08,030 First let's find the Marshall offset. 191 00:21:08,030 --> 00:21:08,660 Tough. 192 00:21:10,820 --> 00:21:12,290 Let's find the offset. 193 00:21:15,590 --> 00:21:17,710 Let's find the offset of this section's count. 194 00:21:17,720 --> 00:21:25,550 Remember from the file we can see the file had its to do weights. 195 00:21:25,550 --> 00:21:30,290 I guess this one and this one is for weight. 196 00:21:30,290 --> 00:21:32,960 So let's just find out. 197 00:21:33,290 --> 00:21:34,150 I pass. 198 00:21:39,730 --> 00:21:40,300 File header. 199 00:21:40,480 --> 00:21:43,960 So in this structure, I want to find the member. 200 00:21:46,190 --> 00:21:48,290 That is a number of sections. 201 00:21:51,160 --> 00:21:54,200 So this thing should be unique. 202 00:21:54,220 --> 00:21:59,490 I mean, this string should be the member of this structure. 203 00:21:59,500 --> 00:22:01,540 So you can see the number of sections. 204 00:22:01,960 --> 00:22:05,980 Make sure all of these uppercase and lowercase are correct. 205 00:22:07,730 --> 00:22:11,170 And we need to set a date to enter the 32. 206 00:22:14,950 --> 00:22:18,310 So you get sections. 207 00:22:19,660 --> 00:22:22,200 Exceptions can't offset. 208 00:22:24,290 --> 00:22:30,230 Now we got the sections count of set piece sections. 209 00:22:32,460 --> 00:22:33,810 Of is equals two. 210 00:22:34,160 --> 00:22:39,530 So from the starting that is does header dot e revenue plus. 211 00:22:41,600 --> 00:22:45,560 The signature is four, so you need to add this one. 212 00:22:49,010 --> 00:22:50,390 Now you will get the. 213 00:22:53,010 --> 00:22:53,930 Sections come. 214 00:23:06,630 --> 00:23:10,590 So the election's count is 16 bits or two bytes. 215 00:23:12,390 --> 00:23:13,920 What we can do is. 216 00:23:16,370 --> 00:23:19,010 Let's just print this P file off. 217 00:23:22,020 --> 00:23:23,280 Sections. 218 00:23:24,090 --> 00:23:25,170 Condorcet. 219 00:23:30,180 --> 00:23:31,230 But as one. 220 00:23:33,810 --> 00:23:35,450 So we can see we got the three. 221 00:23:35,460 --> 00:23:38,430 So I think we are good to go. 222 00:23:41,750 --> 00:23:43,370 Let's go and modify this one. 223 00:24:16,190 --> 00:24:21,910 So let's marshal that right into 16. 224 00:24:21,920 --> 00:24:31,850 So we'll be writing to this, our memory allocated and then after that we can finally save all those 225 00:24:31,850 --> 00:24:32,990 memory into the file. 226 00:24:35,480 --> 00:24:36,380 Base address. 227 00:24:36,380 --> 00:24:39,320 Press Section's count offset. 228 00:24:43,420 --> 00:24:44,450 Sections. 229 00:24:48,150 --> 00:25:00,150 So we need to update the value so we can say anti header, not fire header number of sections plus one. 230 00:25:18,290 --> 00:25:21,860 So we are updating the sections in the memory. 231 00:25:23,420 --> 00:25:26,750 So let's put a breakpoint here and let's run this one. 232 00:25:32,070 --> 00:25:33,150 So we have this. 233 00:25:34,140 --> 00:25:35,510 You can see the P. 234 00:25:35,550 --> 00:25:38,660 So here we can see 0003. 235 00:25:38,670 --> 00:25:40,980 So this is in return. 236 00:25:41,160 --> 00:25:42,990 So zero three is the number of sections. 237 00:25:42,990 --> 00:25:46,800 If I go and step into this one, I should see the four. 238 00:25:47,460 --> 00:25:50,070 So let's run this and we can see the four. 239 00:25:50,070 --> 00:25:56,640 So we have three updated the sections in a similar manner which we are going to update all of this one. 240 00:25:59,290 --> 00:26:00,850 Size of image. 241 00:26:04,310 --> 00:26:08,370 So size of image is so first created. 242 00:26:35,510 --> 00:26:38,570 So let's create a new section header. 243 00:26:46,790 --> 00:26:50,690 That's a new section is equal to a new section. 244 00:26:51,230 --> 00:26:58,310 So we need to update the values of this new section, members like this one. 245 00:26:59,970 --> 00:27:04,900 So new section dot name is equals to. 246 00:27:07,800 --> 00:27:12,060 Encoding, not as key yet by itself. 247 00:27:12,690 --> 00:27:23,670 So here we need to give the name eight characters because later we are going to copy into the memory. 248 00:27:23,670 --> 00:27:25,640 So it's going to give some error. 249 00:27:25,650 --> 00:27:29,790 So let's just do the dot domain 69. 250 00:27:31,500 --> 00:27:33,630 It takes exactly eight characters. 251 00:27:36,960 --> 00:27:39,150 A new section dot. 252 00:27:45,240 --> 00:27:47,070 Number of line numbers zero. 253 00:27:52,520 --> 00:27:53,340 Relocations. 254 00:27:53,350 --> 00:27:53,980 Zero. 255 00:27:58,250 --> 00:27:59,750 This one is also zero. 256 00:28:01,370 --> 00:28:03,770 Now pointer to ras data. 257 00:28:03,770 --> 00:28:17,480 So the pointer to data is the P file length so that the next way to this one we have written the our 258 00:28:17,480 --> 00:28:18,020 circle. 259 00:28:24,970 --> 00:28:26,880 New Section DOT. 260 00:28:40,990 --> 00:28:41,980 Size of raw data. 261 00:28:41,980 --> 00:28:45,850 Size of raw data is this one. 262 00:28:47,740 --> 00:28:51,910 U.S. says so the U.S. size is the size of the data. 263 00:29:00,920 --> 00:29:08,660 A new section dot portugal size what your address so what Chaucer addresses. 264 00:29:10,570 --> 00:29:11,450 Virtual addresses. 265 00:29:11,470 --> 00:29:15,580 You can see the large sections, virtual addresses for 4000. 266 00:29:19,610 --> 00:29:23,600 So let's first define what Chaucer is. 267 00:29:23,600 --> 00:29:31,100 So there is some math you should do for what Schroders or Chaucer sizes share code length. 268 00:29:35,540 --> 00:29:43,190 Now there is a problem I have encountered whenever this virtual size is greater than section alignment. 269 00:29:43,820 --> 00:29:50,420 So that means our section alignment is 1000. 270 00:29:50,720 --> 00:29:59,540 And if the actual size of any of the previous section is 2000, or let's say 1500. 271 00:30:00,840 --> 00:30:08,570 Now what we need to do is we need to divide this one over to a size with this section arrangement. 272 00:30:08,580 --> 00:30:10,800 So 1500 by 8000. 273 00:30:11,190 --> 00:30:16,650 So we use the quotient one. 274 00:30:17,310 --> 00:30:24,350 So Quotient one, we need to add plus one to this one and we need to multiply the section element. 275 00:30:24,360 --> 00:30:25,830 So this gives the 276 00:30:29,250 --> 00:30:34,260 actual virtual size or even the next. 277 00:30:37,180 --> 00:30:38,350 What's your address to this one? 278 00:30:38,350 --> 00:30:40,390 So we got the 2000. 279 00:30:40,390 --> 00:30:42,960 So this 2000 should be added to this. 280 00:30:43,420 --> 00:30:44,290 What sort of size? 281 00:30:44,290 --> 00:30:47,020 So it will be added to 4000. 282 00:30:47,050 --> 00:30:48,760 Now the result will be 6000. 283 00:30:48,760 --> 00:30:55,180 So you can see 4500 virtual size and the new section is 6000. 284 00:30:55,180 --> 00:30:56,050 So it should be. 285 00:30:58,720 --> 00:31:01,450 It should be it should not give any error. 286 00:31:03,520 --> 00:31:10,230 So let's go and get the old sections off. 287 00:31:10,240 --> 00:31:19,030 So to get the last section member of an area so we can say what are the sections dot length minus one. 288 00:31:19,030 --> 00:31:25,450 So this should the last member dot virtual size. 289 00:31:27,050 --> 00:31:30,200 What you say should be diverted by section 11. 290 00:31:30,200 --> 00:31:30,950 So. 291 00:31:33,240 --> 00:31:37,590 Sexual harassment is not optional, but section alignment. 292 00:31:38,860 --> 00:31:41,090 So they should give me the quotient. 293 00:31:42,970 --> 00:31:50,470 And even if the what you're saying is 190 here, so you can see what sort of size is 190, which is 294 00:31:50,470 --> 00:31:52,300 less than the thousand. 295 00:31:52,480 --> 00:31:55,300 So we can say 190 divided by 1000. 296 00:31:55,300 --> 00:31:59,580 You get the value of the question zero zero plus 1000. 297 00:31:59,590 --> 00:32:02,140 So it gives me the value of 5000. 298 00:32:03,730 --> 00:32:08,170 So it should not be a problem of the previous section. 299 00:32:08,170 --> 00:32:09,220 So what you're saying is. 300 00:32:10,950 --> 00:32:11,340 Okay. 301 00:32:11,370 --> 00:32:16,500 So now I'm going to add plus one to this one plus one to this one. 302 00:32:18,340 --> 00:32:22,270 And I'm going to multiply the section amendment. 303 00:32:28,020 --> 00:32:29,300 To this one. 304 00:32:29,310 --> 00:32:41,160 So this gives me the perfect value to be added to the old sections of all the sections. 305 00:32:41,520 --> 00:32:44,250 Length minus one. 306 00:32:45,370 --> 00:32:46,840 Not virtual size. 307 00:32:50,230 --> 00:32:56,200 So that is adding to this, the previous virtual address. 308 00:32:57,800 --> 00:32:58,850 What's your address? 309 00:33:00,050 --> 00:33:05,350 So this entire thing is U.S. dot. 310 00:33:05,990 --> 00:33:07,100 What's your address? 311 00:33:09,090 --> 00:33:10,820 Okay, we are good to go. 312 00:33:10,850 --> 00:33:12,590 My new section is ready. 313 00:33:12,590 --> 00:33:15,440 And one more. 314 00:33:15,620 --> 00:33:17,570 Few more things we need to update our. 315 00:33:20,360 --> 00:33:27,140 This one size of image, sizes of image, size of feathers. 316 00:33:28,490 --> 00:33:37,460 So what we can do is in the headers dot adoption and adoption or dot. 317 00:33:40,050 --> 00:33:40,830 Size of females. 318 00:33:40,830 --> 00:33:43,290 So size of. 319 00:33:44,820 --> 00:33:46,260 Emergency calls to. 320 00:33:51,870 --> 00:33:53,400 The latest sections. 321 00:33:53,430 --> 00:33:54,270 What's your address? 322 00:33:54,280 --> 00:33:55,530 Press choices. 323 00:33:59,910 --> 00:34:03,030 This gives me the latest size of image. 324 00:34:08,290 --> 00:34:08,700 All right. 325 00:34:08,810 --> 00:34:11,750 We need to update this value or. 326 00:34:14,400 --> 00:34:16,530 By finding the offset of this. 327 00:34:18,270 --> 00:34:21,880 I love image, so I'm just going to copy this one. 328 00:34:21,880 --> 00:34:25,510 So it's similar to this updating values. 329 00:34:49,240 --> 00:34:52,990 So let's copy this and paste it in our code. 330 00:34:56,640 --> 00:34:58,710 So we are finding a size of image. 331 00:34:58,710 --> 00:35:04,650 And then the P offset press, signature press. 332 00:35:06,320 --> 00:35:08,960 The file header breast size of image offset. 333 00:35:11,240 --> 00:35:18,710 So we can say this one is updating the mail size. 334 00:35:21,320 --> 00:35:21,490 Okay. 335 00:35:21,590 --> 00:35:27,590 In similar way, you can update the size of headers as well. 336 00:35:37,560 --> 00:35:38,730 So copy this. 337 00:35:38,730 --> 00:35:39,540 And. 338 00:35:47,070 --> 00:35:48,420 So these are factors. 339 00:36:00,550 --> 00:36:02,950 So they see the size of us offset. 340 00:36:11,150 --> 00:36:12,320 Mark shared our. 341 00:36:17,130 --> 00:36:23,970 Best address press DOS Header LFA New Press four signature press 20. 342 00:36:23,970 --> 00:36:24,630 File Header. 343 00:36:24,630 --> 00:36:27,720 Press sizeof header offset. 344 00:36:32,320 --> 00:36:39,830 So at this point, I want to update with Andy that Andy had a dot option. 345 00:36:40,330 --> 00:36:40,630 So. 346 00:36:43,650 --> 00:36:48,720 Option header dot size of headers press. 347 00:36:52,610 --> 00:36:54,650 Martial arts is off. 348 00:36:55,730 --> 00:37:01,580 So we are simply we are adding one section so we can see the size of a male section. 349 00:37:16,320 --> 00:37:18,970 I think, uh, uh, we should be good to go. 350 00:37:18,990 --> 00:37:22,350 So let's put a breakpoint here and let's run this. 351 00:37:27,170 --> 00:37:32,570 And at this point, the sections, a number of sections I'm sorry, sections can't. 352 00:37:35,860 --> 00:37:37,240 It also hit the breakpoints. 353 00:37:37,240 --> 00:37:40,420 So a03 should be changed to zero four. 354 00:37:41,620 --> 00:37:42,880 Yes, we can see. 355 00:37:44,110 --> 00:37:45,550 And now the SEC. 356 00:37:46,330 --> 00:37:50,650 Where is this bullet point so that we can continue at this point? 357 00:37:50,650 --> 00:37:51,430 Immelt says. 358 00:37:51,460 --> 00:37:55,510 So he made size his 4190. 359 00:37:58,420 --> 00:38:00,490 So the new images size will be. 360 00:38:02,460 --> 00:38:03,030 This one. 361 00:38:04,880 --> 00:38:05,060 Now. 362 00:38:05,060 --> 00:38:05,840 What's your address? 363 00:38:05,840 --> 00:38:06,500 Press. 364 00:38:06,530 --> 00:38:07,990 The size what yours is. 365 00:38:08,000 --> 00:38:12,680 So if you click on this one and you can see 5114. 366 00:38:13,340 --> 00:38:18,710 So 5000 is the virtual address and 114 is the virtual size. 367 00:38:20,190 --> 00:38:23,420 So let's continue this one. 368 00:38:23,430 --> 00:38:25,830 We should see size of head offset. 369 00:38:26,640 --> 00:38:29,760 So the size section header is 40 bytes. 370 00:38:31,070 --> 00:38:31,260 So. 371 00:38:33,570 --> 00:38:34,430 So. 372 00:38:34,740 --> 00:38:36,510 40 so. 373 00:38:41,140 --> 00:38:43,660 14 hexadecimal is 28. 374 00:38:43,870 --> 00:38:53,710 So if I add 28 the section size to this to 48 section heterozygous to this to 48, I should get to 70. 375 00:38:54,160 --> 00:38:58,330 So let's run this one and I should see 0270 270. 376 00:38:58,330 --> 00:38:59,890 So we are good to go. 377 00:39:00,130 --> 00:39:01,660 One last thing is. 378 00:39:04,300 --> 00:39:09,460 We need to copy the section header information. 379 00:39:12,580 --> 00:39:14,080 Right after this section. 380 00:39:15,420 --> 00:39:17,850 So how do you get the offset is? 381 00:39:23,280 --> 00:39:28,480 Anti header dot option file header a number of sections. 382 00:39:31,770 --> 00:39:35,340 This gives me the old number of sections. 383 00:39:35,340 --> 00:39:36,360 That is three. 384 00:39:57,090 --> 00:40:03,390 What we can do is we can directly rate using this one size of factors. 385 00:40:05,010 --> 00:40:06,260 So you can copy this one. 386 00:40:06,270 --> 00:40:07,950 This is the character offset. 387 00:40:07,950 --> 00:40:09,390 We can write. 388 00:40:09,390 --> 00:40:09,900 So. 389 00:40:12,260 --> 00:40:13,720 Martial art. 390 00:40:17,920 --> 00:40:21,140 Separate this section structure. 391 00:40:21,160 --> 00:40:23,200 We need to convert this into byte area. 392 00:40:23,680 --> 00:40:26,530 So first, let's get some memory. 393 00:40:43,270 --> 00:40:45,640 So we had allocated some memory. 394 00:40:45,850 --> 00:40:48,610 Uh, and it can be pointed by Pointer. 395 00:40:56,580 --> 00:40:59,070 And we need to master the structure to the point. 396 00:40:59,220 --> 00:41:03,840 So the structure is new section pointer. 397 00:41:04,140 --> 00:41:04,650 True. 398 00:41:05,610 --> 00:41:08,160 So at this point, the section will be. 399 00:41:13,480 --> 00:41:20,980 Copied into this pointer will be pointed to that structure data. 400 00:41:21,340 --> 00:41:24,280 So then we can copy this one. 401 00:41:44,690 --> 00:41:47,750 You can copy into this new section by its. 402 00:41:55,630 --> 00:42:03,940 So first one is pointer and the next one is new section by its start index and then this new section 403 00:42:03,940 --> 00:42:06,280 by bytes dot length. 404 00:42:07,150 --> 00:42:08,830 So that's the breakpoint. 405 00:42:08,830 --> 00:42:10,210 And let's run this. 406 00:42:11,940 --> 00:42:13,970 And pipe pointer. 407 00:42:28,390 --> 00:42:29,770 So let's run this one. 408 00:42:29,770 --> 00:42:34,310 And here we can see the structure, a new section structure. 409 00:42:34,330 --> 00:42:41,410 You can see the first one is the name Dummy 69, and the next one are the members of the structure. 410 00:42:41,980 --> 00:42:46,770 Those are 40 bytes were written into this one. 411 00:42:46,780 --> 00:42:51,610 So we can we are copying from this one to the new section bytes. 412 00:42:53,420 --> 00:42:55,280 So we are good to go now. 413 00:42:55,670 --> 00:43:03,470 And final thing is, we need to copy this by today to exactly before this section header. 414 00:43:08,220 --> 00:43:09,810 So my shelled art. 415 00:43:11,770 --> 00:43:12,550 Copy. 416 00:43:14,390 --> 00:43:19,070 New section bytes start index zero destination is. 417 00:43:21,980 --> 00:43:27,740 Based address press and d header dot option header dot size of headers. 418 00:43:33,070 --> 00:43:35,350 New section bytes dot. 419 00:44:12,380 --> 00:44:14,870 So let's put a break here and run this. 420 00:44:21,810 --> 00:44:24,630 And the base address is this one. 421 00:44:26,960 --> 00:44:32,360 So here we can see the after this fifth section after 45. 422 00:44:32,390 --> 00:44:33,920 This is the end of the section. 423 00:44:34,070 --> 00:44:37,910 We should see the new section here, the dummy section. 424 00:44:38,150 --> 00:44:39,380 So let's run this. 425 00:44:39,530 --> 00:44:41,090 And here we can see. 426 00:44:42,560 --> 00:44:45,020 The sexual information. 427 00:44:45,020 --> 00:44:47,750 So we have successfully written this one. 428 00:44:50,250 --> 00:44:52,560 So we have successfully added the section. 429 00:44:52,560 --> 00:44:55,230 All we need to do is now we need to 430 00:44:59,490 --> 00:45:03,030 create an area. 431 00:45:04,590 --> 00:45:07,230 Let's say a new file is equals two new byte of. 432 00:45:09,020 --> 00:45:10,130 Total size. 433 00:45:13,950 --> 00:45:19,040 Want to share our copy sources. 434 00:45:19,050 --> 00:45:21,300 The best address. 435 00:45:27,320 --> 00:45:28,210 New file 436 00:45:30,950 --> 00:45:31,580 size. 437 00:45:32,540 --> 00:45:37,820 So you're copying the entire, uh, memory bytes into the file. 438 00:45:38,240 --> 00:45:39,950 So we can see a file dot. 439 00:45:40,520 --> 00:45:41,180 Right. 440 00:45:45,900 --> 00:45:46,890 All bites. 441 00:45:48,530 --> 00:45:54,020 So we can say the smarter teaming tools. 442 00:45:58,720 --> 00:45:59,530 And then you fight. 443 00:46:02,690 --> 00:46:04,070 So it's going to run this. 444 00:46:07,990 --> 00:46:10,770 And here we can see the tree has been popped up. 445 00:46:10,780 --> 00:46:14,560 So let's go and view that character in see where. 446 00:46:17,010 --> 00:46:23,640 And here we can see the number of sections has been increased to four and the size of the size of others. 447 00:46:23,640 --> 00:46:27,060 And you can see there is a dummy section. 448 00:46:31,050 --> 00:46:33,600 So the characters are of characteristics. 449 00:46:33,930 --> 00:46:37,890 So you can copy the characteristics of this one. 450 00:46:42,530 --> 00:46:44,300 New section dot. 451 00:46:44,300 --> 00:46:48,500 So these characteristics test whether section is readable or executable. 452 00:46:49,190 --> 00:46:59,240 So there is a enumeration data section, flags a dot memory execute and data section flags dot memory 453 00:46:59,240 --> 00:47:04,160 read and data section flags dot. 454 00:47:07,520 --> 00:47:10,010 I think it's for. 455 00:47:12,240 --> 00:47:16,950 So if you hold on to this, you will see the enum code executable readable. 456 00:47:19,300 --> 00:47:19,750 Content. 457 00:47:20,350 --> 00:47:21,810 So we are good to go now. 458 00:47:21,820 --> 00:47:23,020 So let's run this again. 459 00:47:23,020 --> 00:47:30,460 And now I rewrote this one and we should see the characteristics, same as each section. 460 00:47:30,460 --> 00:47:32,530 You can change these characteristics as well. 461 00:47:33,590 --> 00:47:36,890 You can just say readable. 462 00:47:37,710 --> 00:47:48,480 So that server, this video you can add if you want to add another section, you can re randomize this 463 00:47:48,480 --> 00:47:52,950 number and you can go in a loop of adding sections.