Rev 61 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 61 | Rev 91 | ||
---|---|---|---|
Line 305... | Line 305... | ||
305 | call get_app_params ;parse header fields |
305 | call get_app_params ;parse header fields |
306 | test esi,esi |
306 | test esi,esi |
307 | jz .cleanfailed |
307 | jz .cleanfailed |
Line 308... | Line 308... | ||
308 | 308 | ||
309 | mov eax,[new_process_place] |
- | |
310 | call create_app_cr3_table ;create page directory for new process |
309 | mov eax,[new_process_place] |
- | 310 | inc ecx ; -0x1E = no memory |
|
311 | inc ecx ; -0x1E = no memory |
311 | call create_app_cr3_table ;create page directory for new process |
312 | test eax,eax |
312 | test eax,eax |
Line 313... | Line 313... | ||
313 | jz .cleanfailed_mem |
313 | jz .cleanfailed_mem |
Line 561... | Line 561... | ||
561 | lea esi,[0xC400+esi*2] |
561 | lea esi,[0xC400+esi*2] |
562 | call windowactivate ;gui initialization |
562 | call windowactivate ;gui initialization |
Line 563... | Line 563... | ||
563 | 563 | ||
564 | mov ebx,[new_process_place] |
564 | mov ebx,[new_process_place] |
565 | shl ebx,5 |
- | |
566 | mov [0x3000+ebx+0xa],byte 0 ;set process state - running |
565 | shl ebx,5 |
567 | ; set if debuggee |
566 | ; set if debuggee |
568 | test byte [esp+28], 1 |
567 | test byte [esp+28], 1 |
569 | jz .no_debug |
568 | jz .no_debug |
570 | mov [0x3000+ebx+0xa],byte 1 ;set process state - suspended |
569 | mov [0x3000+ebx+0xa], byte 1 ; set process state - suspended |
571 | mov eax,[0x3000] |
570 | mov eax, [0x3000] |
- | 571 | mov [0x80000+ebx*8+0xac], eax ;set debugger PID - current |
|
572 | mov [0x80000+ebx*8+0xac],eax ;set debugger PID - current |
572 | jmp .debug |
- | 573 | .no_debug: |
|
- | 574 | mov [0x3000+ebx+0xa], byte 0 ; set process state - running |
|
Line 573... | Line 575... | ||
573 | .no_debug: |
575 | .debug: |
574 | 576 | ||
Line 575... | Line 577... | ||
575 | mov esi,new_process_running |
577 | mov esi,new_process_running |
Line 1267... | Line 1269... | ||
1267 | mov ecx, -0x1F ; not Menuet/Kolibri executable |
1269 | mov ecx, -0x1F ; not Menuet/Kolibri executable |
1268 | test esi,esi |
1270 | test esi,esi |
1269 | jz .cleanfailed |
1271 | jz .cleanfailed |
Line 1270... | Line 1272... | ||
1270 | 1272 | ||
- | 1273 | mov eax,[new_process_place] |
|
1271 | mov eax,[new_process_place] |
1274 | inc ecx ; -0x1E = no memory |
1272 | call create_app_cr3_table ;create page directory |
1275 | call create_app_cr3_table ;create page directory |
1273 | test eax,eax |
- | |
1274 | inc ecx ; -0x1E = no memory |
1276 | test eax,eax |
Line 1275... | Line 1277... | ||
1275 | jz .cleanfailed_mem |
1277 | jz .cleanfailed_mem |
Line 1276... | Line 1278... | ||
1276 | 1278 | ||
Line 1390... | Line 1392... | ||
1390 | mov [application_table_status],0 |
1392 | mov [application_table_status],0 |
1391 | sti |
1393 | sti |
1392 | ret |
1394 | ret |
1393 | end if |
1395 | end if |
Line -... | Line 1396... | ||
- | 1396 | ||
1394 | 1397 | ; \begin{diamond} |
|
- | 1398 | include 'debug.inc' |
|
- | 1399 | ||
- | 1400 | fs_execute: |
|
- | 1401 | ; ebx - cmdline |
|
- | 1402 | ; edx - flags |
|
- | 1403 | ; ebp - full filename |
|
- | 1404 | ; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it |
|
- | 1405 | pushad |
|
- | 1406 | ; check filename length - with terminating NULL must be no more than 1024 symbols |
|
- | 1407 | mov edi, ebp |
|
- | 1408 | mov ecx, 1024 |
|
- | 1409 | xor eax, eax |
|
- | 1410 | repnz scasb |
|
- | 1411 | jz @f |
|
- | 1412 | popad |
|
- | 1413 | mov eax, -ERROR_FILE_NOT_FOUND |
|
- | 1414 | ret |
|
- | 1415 | @@: |
|
- | 1416 | ||
- | 1417 | mov esi, new_process_loading |
|
- | 1418 | call sys_msg_board_str ; write message to message board |
|
- | 1419 | ||
- | 1420 | ; lock application_table_status mutex |
|
- | 1421 | .table_status: |
|
- | 1422 | cli |
|
- | 1423 | cmp [application_table_status], 0 |
|
- | 1424 | jz .stf |
|
- | 1425 | sti |
|
- | 1426 | call change_task |
|
- | 1427 | jmp .table_status |
|
- | 1428 | .stf: |
|
- | 1429 | call set_application_table_status |
|
- | 1430 | push ebx ; save command line pointer for add_app_parameters |
|
- | 1431 | ||
- | 1432 | call find_new_process_place ; find new process slot |
|
- | 1433 | call safe_sti |
|
- | 1434 | test eax, eax |
|
- | 1435 | mov ecx, -0x20 ; too many processes |
|
- | 1436 | jz .failed |
|
- | 1437 | ||
- | 1438 | ; write application name |
|
- | 1439 | push edi |
|
- | 1440 | mov ecx, edi |
|
- | 1441 | sub ecx, ebp |
|
- | 1442 | mov [appl_path], ebp |
|
- | 1443 | mov [appl_path_size], ecx |
|
- | 1444 | dec edi |
|
- | 1445 | std |
|
- | 1446 | mov al, '/' |
|
- | 1447 | repnz scasb |
|
- | 1448 | cld |
|
- | 1449 | jnz @f |
|
- | 1450 | inc edi |
|
- | 1451 | @@: |
|
- | 1452 | inc edi |
|
- | 1453 | ; now edi points to name without path |
|
- | 1454 | mov esi, edi |
|
- | 1455 | mov ecx, 8 ; 8 chars for name |
|
- | 1456 | mov edi, [new_process_place] |
|
- | 1457 | shl edi, cl |
|
- | 1458 | add edi, 0x80000 |
|
- | 1459 | .copy_process_name_loop: |
|
- | 1460 | lodsb |
|
- | 1461 | cmp al, '.' |
|
- | 1462 | jz .copy_process_name_done |
|
- | 1463 | test al, al |
|
- | 1464 | jz .copy_process_name_done |
|
- | 1465 | stosb |
|
- | 1466 | loop .copy_process_name_loop |
|
- | 1467 | .copy_process_name_done: |
|
- | 1468 | mov al, ' ' |
|
- | 1469 | rep stosb |
|
- | 1470 | pop eax |
|
- | 1471 | mov cl, 3 ; 3 chars for extension |
|
- | 1472 | dec esi |
|
- | 1473 | @@: |
|
- | 1474 | dec eax |
|
- | 1475 | cmp eax, esi |
|
- | 1476 | jbe .copy_process_ext_done |
|
- | 1477 | cmp byte [eax], '.' |
|
- | 1478 | jnz @b |
|
- | 1479 | lea esi, [eax+1] |
|
- | 1480 | .copy_process_ext_loop: |
|
- | 1481 | lodsb |
|
- | 1482 | test al, al |
|
- | 1483 | jz .copy_process_ext_done |
|
- | 1484 | stosb |
|
- | 1485 | loop .copy_process_ext_loop |
|
- | 1486 | .copy_process_ext_done: |
|
- | 1487 | mov al, ' ' |
|
- | 1488 | rep stosb |
|
- | 1489 | ||
- | 1490 | ; read header |
|
- | 1491 | lea eax, [esp+8+36] |
|
- | 1492 | mov edi, 0x90000 |
|
- | 1493 | call dword [eax-4] |
|
- | 1494 | mov ecx, eax |
|
- | 1495 | neg ecx |
|
- | 1496 | jnz .cleanfailed |
|
- | 1497 | ; check menuet signature |
|
- | 1498 | mov ecx, -0x1F |
|
- | 1499 | cmp dword [0x90000], 'MENU' |
|
- | 1500 | jnz .cleanfailed |
|
- | 1501 | cmp word [0x90004], 'ET' |
|
- | 1502 | jnz .cleanfailed |
|
- | 1503 | call get_app_params |
|
- | 1504 | mov ecx, -0x1F |
|
- | 1505 | test esi, esi |
|
- | 1506 | jz .cleanfailed |
|
- | 1507 | ||
- | 1508 | mov eax, [new_process_place] |
|
- | 1509 | inc ecx ; -0x1E = no memory |
|
- | 1510 | call create_app_cr3_table |
|
- | 1511 | test eax, eax |
|
- | 1512 | jz .cleanfailed_mem |
|
- | 1513 | ||
- | 1514 | call MEM_Get_Linear_Address |
|
- | 1515 | ||
- | 1516 | mov ebx, std_application_base_address |
|
- | 1517 | mov ecx, [app_mem] |
|
- | 1518 | add ecx, 4095 |
|
- | 1519 | shr ecx, 12 |
|
- | 1520 | mov edx, eax ; edx - linear address of page directory |
|
- | 1521 | call mem_alloc_specified_region |
|
- | 1522 | mov ecx, -0x1E ; no memory |
|
- | 1523 | test eax, eax |
|
- | 1524 | jz .cleanfailed_mem1 |
|
- | 1525 | ||
- | 1526 | add edx, std_application_base_address shr 20 |
|
- | 1527 | mov eax, [edx] |
|
- | 1528 | and eax, not 4095 |
|
- | 1529 | call MEM_Get_Linear_Address |
|
- | 1530 | push edx ; save pointer to first page table |
|
- | 1531 | mov edx, eax |
|
- | 1532 | ; read file |
|
- | 1533 | ; first block is already read to 0x90000 |
|
- | 1534 | mov eax, [edx] |
|
- | 1535 | and eax, not 0xFFF |
|
- | 1536 | call MEM_Get_Linear_Address |
|
- | 1537 | mov esi, 0x90000 |
|
- | 1538 | mov edi, eax |
|
- | 1539 | mov ecx, 512/4 |
|
- | 1540 | rep movsd |
|
- | 1541 | sub edi, eax |
|
- | 1542 | .loop1: |
|
- | 1543 | ; [esp] = pointer to current page directory entry |
|
- | 1544 | ; edx = pointer to current page table |
|
- | 1545 | ; edi = offset in page |
|
- | 1546 | mov eax, [edx] |
|
- | 1547 | and eax, not 0xFFF |
|
- | 1548 | call MEM_Get_Linear_Address |
|
- | 1549 | push edi |
|
- | 1550 | add edi, eax |
|
- | 1551 | lea eax, [esp+8+36+8] |
|
- | 1552 | call dword [eax-4] |
|
- | 1553 | pop edi |
|
- | 1554 | test eax, eax |
|
- | 1555 | jnz .endloop1 |
|
- | 1556 | add edi, 512 ; new offset |
|
- | 1557 | cmp edi, 4096 |
|
- | 1558 | jb .loop1 |
|
- | 1559 | xor edi, edi |
|
- | 1560 | add edx, 4 ; go to next page |
|
- | 1561 | test edx, 4096-1 |
|
- | 1562 | jnz .loop1 |
|
- | 1563 | pop eax |
|
- | 1564 | add eax, 4 ; go to next directory entry |
|
- | 1565 | push eax |
|
- | 1566 | mov eax, [eax] |
|
- | 1567 | and eax, not 0xFFF |
|
- | 1568 | call MEM_Get_Linear_Address |
|
- | 1569 | mov edx, eax |
|
- | 1570 | jmp .loop1 |
|
- | 1571 | .endloop1: |
|
- | 1572 | pop edx |
|
- | 1573 | cmp eax, 6 |
|
- | 1574 | jnz .cleanfailed_mem2 |
|
- | 1575 | call new_start_application_fl.add_app_parameters |
|
- | 1576 | mov [esp+28], eax |
|
- | 1577 | popad |
|
- | 1578 | ret |
|
- | 1579 | ||
- | 1580 | .cleanfailed_mem2: |
|
- | 1581 | ; file read error; free all allocated mem |
|
- | 1582 | mov ecx, eax |
|
- | 1583 | neg ecx |
|
- | 1584 | mov eax, [new_process_place] |
|
- | 1585 | call dispose_app_cr3_table |
|
- | 1586 | jmp .cleanfailed |
|
- | 1587 | .cleanfailed_mem1: |
|
- | 1588 | ; there is mem for directory entry, but there is no mem for pages |
|
- | 1589 | ; so free directory entry |
|
- | 1590 | mov eax, [new_process_place] |
|
- | 1591 | shl eax, 8 |
|
- | 1592 | mov eax, [0x80000+eax+0xB8] |
|
- | 1593 | call MEM_Free_Page |
|
- | 1594 | .cleanfailed_mem: |
|
- | 1595 | ; there is no mem for directory entry, display message |
|
- | 1596 | mov esi, start_not_enough_memory |
|
- | 1597 | call sys_msg_board_str |
|
- | 1598 | .cleanfailed: |
|
- | 1599 | push ecx |
|
- | 1600 | ; clean process name, this avoid problems with @panel |
|
- | 1601 | mov edi, [new_process_place] |
|
- | 1602 | shl edi, 8 |
|
- | 1603 | add edi, 0x80000 |
|
- | 1604 | mov ecx, 11 |
|
- | 1605 | mov al, ' ' |
|
- | 1606 | rep stosb |
|
- | 1607 | pop eax |
|
- | 1608 | .failed: |
|
- | 1609 | pop ebx |
|
- | 1610 | mov [esp+28], eax |
|
- | 1611 | popad |
|
- | 1612 | mov [application_table_status], 0 |
|
- | 1613 | call safe_sti |
|
- | 1614 | ret |