Advertisement
ItsTotallyRSX

Test Cpp

Jun 13th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. *
  2. Purpose: Xenus NTOS emulator entrypoint.
  3. Author: Reece W.
  4. License: All Rights Reserved J. Reece Wilson
  5. */
  6.  
  7. #include <xenus_lazy.h>
  8. #include <liblinux.hpp>
  9.  
  10. #include <ITypes\ITaskStruct.hpp>
  11.  
  12. // C++ test
  13.  
  14. class TestClass
  15. {
  16. size_t _seconds;
  17. public:
  18. TestClass(size_t seconds)
  19. {
  20. _seconds = seconds;
  21. }
  22.  
  23. void test()
  24. {
  25. printf("This is C++, and I'm fucking off for %i seconds\n", _seconds);
  26. ssleep(_seconds);
  27.  
  28. printf("Genetic failure error code: %i %i \n", XENUS_ERROR_GENERIC_FAILURE, kErrorGenericFailure);
  29. printf("Nested call, no error, status code: %i %i \n", XENUS_STATUS_NESTED_CALL, kStatusNestedCall);
  30. };
  31. };
  32.  
  33. // current/task_struct test
  34.  
  35. void test_current()
  36. {
  37. ITaskStruct test(current);
  38.  
  39. print("Current (struct task_struct): \n");
  40. printf("State: %p \n", test.get_var_state().GetInt()); //state hasn't been implemented, but we can still read/write to it via a slightly more resource intensive variable int datatype
  41. printf("On CPU: %i \n", test.get_on_cpu()); //on_cpu has been implemented; we can access it with get_on_cpu & set_on_cpu
  42. }
  43.  
  44. static mod_global_data_t ntos_module = { 0 };
  45.  
  46. bool subsystem_ntos_init(mod_dependency_list_p deps)
  47. {
  48. return true;
  49. }
  50.  
  51. int subsystem_ntos_start()
  52. {
  53. test_current();
  54.  
  55. (new TestClass(3))->test();
  56. return 1;
  57. }
  58.  
  59. void subsystem_ntos_shutdown()
  60. {
  61.  
  62. }
  63.  
  64. void entrypoint(xenus_entrypoint_ctx_p context)
  65. {
  66. /* Do note, the IAT is still NULL'd at this moment in time! */
  67. context->size = sizeof(xenus_entrypoint_ctx_t);
  68. context->description = "An emulation attempt of the Microsoft Windows� Kernel (ntos.exe).";
  69. context->copyright = "All rights reserved, Reece Wilson (2018)";
  70. context->init = subsystem_ntos_init;
  71. context->start = subsystem_ntos_start;
  72. context->shutdown = subsystem_ntos_shutdown;
  73. context->dependencies.count = 0;
  74. context->static_data = &ntos_module;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement