diff --git a/buffer-overflow/src/scenes/overwriting-locals.tsx b/buffer-overflow/src/scenes/overwriting-locals.tsx index 0e87261..00e6cc6 100644 --- a/buffer-overflow/src/scenes/overwriting-locals.tsx +++ b/buffer-overflow/src/scenes/overwriting-locals.tsx @@ -1,6 +1,6 @@ -import {Circle, Layout, Ray, Rect, Txt, makeScene2D} from '@motion-canvas/2d'; -import { CodeBlock, remove, insert, edit } from '@motion-canvas/2d/lib/components/CodeBlock'; -import {Reference, all, beginSlide, createRef, createSignal} from '@motion-canvas/core'; +import {Circle, Layout, Node, Ray, Rect, Txt, makeScene2D} from '@motion-canvas/2d'; +import { CodeBlock, remove, insert, edit, lines } from '@motion-canvas/2d/lib/components/CodeBlock'; +import {DEFAULT, Reference, all, beginSlide, createRef, createSignal} from '@motion-canvas/core'; const BACKGROUND = '#282C34'; const RED = '#E06C75'; @@ -204,4 +204,121 @@ export default makeScene2D(function* (view) { yield* beginSlide('Assembly code with header'); + + yield* code().selection(lines(1), 1); + yield* code().selection([...lines(1), ...lines(25)], 1); + + yield* beginSlide('return code highlighted'); + + yield* code().selection(lines(2), 1); + yield* code().selection([...lines(2), ...lines(8, 9), ...lines(17, 18)], 1); + + yield* beginSlide('local_c highlighted'); + + yield* code().selection(lines(3), 1); + yield* code().selection([...lines(3), ...lines(10, 13), ...lines(15)], 1); + + yield* beginSlide('local_30 highlighted'); + + // memory visualization + + const rect = createRef(); + const rbpRect = createRef(); + const local_cRect = createRef(); + const local_30Rect = createRef(); + + view.add( + + + + + + + + + + + + + + ); + + yield* all( + code().selection(DEFAULT, .5), + code().x(-code().width() / 2, 1), + rect().opacity(1, .5), + rect().x(rect().width() / 2 + 150, 1) + ); + + const writeArrow = createRef(); + const metaInfo = createRef(); + view.add( + + rbpRect().topRight().addX(rect().x() + 16)} text="RBP" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + rbpRect().right().addX(rect().x() + 16)} text="8" fill={GRAY} fontSize={36} /> + rbpRect().bottomRight().addX(rect().x() + 16)} text="RBP - 0x8" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + local_cRect().right().addX(rect().x() + 16)} text="4" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + local_cRect().bottomRight().addX(rect().x() + 16)} text="RBP - 0xC" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + local_30Rect().right().addX(rect().x() + 16)} text="44" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + local_30Rect().bottomRight().addX(rect().x() + 16)} text={"RSP\n= RBP - 0x38"} fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + ) + + let writeArrowTo = writeArrow().to(); + writeArrowTo.y = local_30Rect().y() - local_30Rect().height() / 2; + + yield* all( + metaInfo().opacity(1, 1), + writeArrow().to(writeArrowTo, 1) + ); + + yield* beginSlide('Memory visualization'); }); \ No newline at end of file