Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. // ConsoleApplication2.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. //#include "stdafx.h"
  5. #include <iostream>
  6. #include <ctime>
  7. #include <windows.h>
  8. #include <psapi.h>
  9. #include <condition_variable>
  10. #include <processthreadsapi.h>
  11. #include <winbase.h>
  12. #include <time.h>
  13.  
  14. void functie() {
  15. unsigned int a, b, c, d, aux;
  16. unsigned int x;
  17. int k;
  18. char vendor[13];
  19.  
  20. __asm {
  21. pushfd
  22. pop ecx
  23. mov b, ecx
  24. mov aux, ecx
  25. }
  26.  
  27. x = b ^ (1 << 21);
  28. __asm {
  29. push x
  30. popfd
  31. }
  32.  
  33. __asm {
  34. pushfd
  35. pop ecx
  36. mov b, ecx
  37. }
  38.  
  39. if (b == x) {
  40. k = 1;
  41. printf("registrul EFLAGS se poate modifica \n");
  42. }
  43. else {
  44. printf("registrul EFLAGS nu se poate modifica \n");
  45. return;
  46. }
  47. __asm {
  48. push aux
  49. popfd
  50. }
  51. if (k) {
  52. a = 0;
  53. char vendor[13];
  54.  
  55. __asm {
  56. mov eax, a
  57. cpuid
  58. mov DWORD PTR vendor, EBX
  59. mov DWORD PTR vendor + 4, EDX
  60. mov DWORD PTR vendor + 8, ECX
  61. }
  62.  
  63. vendor[12] = 0;
  64.  
  65. printf("%s\n", vendor);
  66.  
  67. a = 1;
  68. int modelNumber, familyCode, extendedMode, processorType, extendedFamily;
  69. __asm {
  70. mov eax, a
  71. cpuid
  72. mov b, eax
  73. }
  74. modelNumber = (b >> 4) & 15;
  75. familyCode = (b >> 8) & 15;
  76. processorType= (b >> 12) & 3;
  77. extendedMode = (b >> 16) & 15;
  78. extendedFamily = (b >> 20) & 255;
  79. printf("%d %d %d %d %d\n", extendedFamily, extendedMode, processorType, familyCode, modelNumber );
  80.  
  81. a = 1;
  82. int brandId;
  83. __asm {
  84. mov eax, a
  85. cpuid
  86. mov b, ebx
  87. }
  88. brandId = b&255;
  89. printf("%d\n", brandId);
  90.  
  91. a = 1;
  92. int flags;
  93. __asm {
  94. mov eax, a
  95. cpuid
  96. mov b, ecx
  97. }
  98. flags = b;
  99. if (b & 1)
  100. printf("FPU\n");
  101. if ((b >>1) & 1)
  102. printf("VME\n");
  103. if ((b >> 2) & 1)
  104. printf("DE\n");
  105. if ((b >> 3) & 1)
  106. printf("PSE\n");
  107. a = 11;
  108. b = 1;
  109. __asm {
  110. mov eax, a
  111. mov ecx, b
  112. cpuid
  113. mov b, ebx
  114. }
  115. printf("%d\n",b & (256*256-1));
  116.  
  117. while (1) {
  118. a = 2;
  119. __asm {
  120. mov eax, a
  121. cpuid
  122. mov a, eax
  123. mov b, ebx
  124. mov c, ecx
  125. mov d, edx
  126. }
  127. if (!(b >> 31)) {
  128. printf("b ");
  129. printf("%d %d %d %d\n", (b >> 24) & 255, (b >> 16) & 255, (b >> 8) & 255, b & 255);
  130. }
  131. if (!(c >> 31)) {
  132. printf("c ");
  133. printf("%d %d %d %d\n", (c >> 24) & 255, (c >> 16) & 255, (c >> 8) & 255, c & 255);
  134. }
  135. if (!(d >> 31)) {
  136. printf("d ");
  137. printf("%d %d %d %d\n", (d >> 24) & 255, (d >> 16) & 255, (d >> 8) & 255, d & 255);
  138. }
  139. if ((a & 255) == 1)
  140. break;
  141. }
  142.  
  143. }
  144.  
  145.  
  146. }
  147.  
  148.  
  149.  
  150. int main()
  151. {
  152. functie();
  153. system("pause");
  154. return 0;
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement