@@ -47,6 +47,7 @@ typedef uint32_t socklen_t;
47
47
48
48
struct PerProcessSyscallData {
49
49
Sheet* window_sheet;
50
+ uint32_t * window_buf;
50
51
int num_getdents64_called;
51
52
// for opening normal file: fd = 6
52
53
int idx_in_root_files;
@@ -556,20 +557,28 @@ __attribute__((ms_abi)) extern "C" void SyscallHandler(uint64_t* args) {
556
557
return ;
557
558
}
558
559
ysize = -ysize;
560
+ if (ysize > 2048 || xsize > 2048 ) {
561
+ kprintf (" msync: create window: window too large: %dx%d\n " , xsize, ysize);
562
+ args[0 ] = static_cast <uint64_t >(-1 );
563
+ return ;
564
+ }
559
565
auto pid = liumos->scheduler ->GetCurrentProcess ().GetID ();
560
566
auto & ppdata = per_process_syscall_data[pid];
561
567
auto & sheet = ppdata.window_sheet ;
568
+ auto & buf = ppdata.window_buf ;
562
569
if (!sheet) {
563
570
kprintf (" offset_to_data = %d, xsize = %d, ysize = %d\n " , offset_to_data,
564
571
xsize, ysize);
565
572
// TODO(hikalium): allocate this backing sheet on fopen.
566
573
sheet = AllocKernelMemory<Sheet*>(sizeof (Sheet));
574
+ buf = AllocKernelMemory<uint32_t *>(xsize * ysize * 4 );
567
575
bzero (sheet, sizeof (Sheet));
568
- sheet->Init (reinterpret_cast <uint32_t *>(addr + offset_to_data), xsize,
569
- ysize, xsize, 0 , 0 );
576
+ sheet->Init (buf, xsize, ysize, xsize, 0 , 0 );
570
577
kprintf (" vram_sheet is at %p\n " , liumos->vram_sheet );
571
578
sheet->SetParent (liumos->vram_sheet );
572
579
}
580
+ memcpy (buf, reinterpret_cast <uint32_t *>(addr + offset_to_data),
581
+ xsize * ysize * 4 );
573
582
sheet->Flush (0 , 0 , xsize, ysize);
574
583
args[0 ] = 0 ;
575
584
return ;
0 commit comments