Guest User

CPlusPlus Thread

a guest
Dec 6th, 2017
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. For some reason my SetPixel external CrossHair isn't working- it's based off of another source, but almost completely rewritten to make it neater (IMHO). Here is the output (no errors when building):
  2.  
  3. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Users\Levi\Documents\Visual Studio 2012\Projects\[MPGH Public] External CrossHair v1.0\Release\[MPGH Public] External CrossHair v1.0.exe'. Symbols loaded.
  4. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
  5. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
  6. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
  7. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
  8. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\win32u.dll'. Cannot find or open the PDB file.
  9. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
  10. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32full.dll'. Cannot find or open the PDB file.
  11. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp_win.dll'. Cannot find or open the PDB file.
  12. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbase.dll'. Cannot find or open the PDB file.
  13. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110.dll'. Cannot find or open the PDB file.
  14. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110.dll'. Cannot find or open the PDB file.
  15. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
  16. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Cannot find or open the PDB file.
  17. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
  18. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
  19. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
  20. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Cannot find or open the PDB file.
  21. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
  22. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Cannot find or open the PDB file.
  23. '[MPGH Public] External CrossHair v1.0.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
  24. The program '[92] [MPGH Public] External CrossHair v1.0.exe' has exited with code -1073741510 (0xc000013a).
  25.  
  26. Here is the code I have written/modified:
  27. #include <Windows.h>
  28. #include <iostream>
  29. #include <math.h>
  30.  
  31. #define WIN32_LEAN_AND_MEAN
  32.  
  33. namespace CrossHair_Variables {
  34.     int Size;
  35.     namespace Color {
  36.         int Red;
  37.         int Green;
  38.         int Blue;
  39.     };
  40. };
  41.  
  42. int main() {
  43.     std::cout << "Crosshair size in pixels:\n";
  44.     std::cin >> CrossHair_Variables::Size;
  45.     if((CrossHair_Variables::Size % 2) == 0) {
  46.         CrossHair_Variables::Size += 1;
  47.     };
  48.     system("cls");
  49.     std::cout << "Crosshair color (Red of RGB):\n";
  50.     std::cin >> CrossHair_Variables::Color::Red;
  51.     if (CrossHair_Variables::Color::Red > 255) {
  52.         CrossHair_Variables::Color::Red = 255;
  53.     }
  54.     else if (CrossHair_Variables::Color::Red < 0) {
  55.         CrossHair_Variables::Color::Red = 0;
  56.     };
  57.     system("cls");
  58.     std::cout << "Crosshair color (Green of RGB):\n";
  59.     std::cin >> CrossHair_Variables::Color::Green;
  60.     if (CrossHair_Variables::Color::Green > 255) {
  61.         CrossHair_Variables::Color::Green = 255;
  62.     }
  63.     else if (CrossHair_Variables::Color::Green < 0) {
  64.         CrossHair_Variables::Color::Green = 0;
  65.     };
  66.     system("cls");
  67.     std::cout << "Crosshair color (Blue of RGB):\n";
  68.     std::cin >> CrossHair_Variables::Color::Blue;
  69.     if (CrossHair_Variables::Color::Blue > 255) {
  70.         CrossHair_Variables::Color::Blue = 255;
  71.     }
  72.     else if (CrossHair_Variables::Color::Blue < 0) {
  73.         CrossHair_Variables::Color::Blue = 0;
  74.     };
  75.     system("cls");
  76.     std::cout << "Loading CrossHair..";
  77.     int BaseX = ((GetSystemMetrics(SM_CXSCREEN) / 2) - ((CrossHair_Variables::Size - 1) / 2));
  78.     int BaseY = ((GetSystemMetrics(SM_CYSCREEN) / 2) - ((CrossHair_Variables::Size - 1) / 2));
  79.     COLORREF Color = RGB(
  80.         CrossHair_Variables::Color::Red,
  81.         CrossHair_Variables::Color::Green,
  82.         CrossHair_Variables::Color::Blue
  83.     );
  84.     while (true) {
  85.         for(int Index = 0; (Index < CrossHair_Variables::Size); Index++) {
  86.             SetPixel(
  87.                 (HDC)HWND_DESKTOP,
  88.                 (BaseX + Index),
  89.                 (BaseY + ((CrossHair_Variables::Size - 1) / 2)),
  90.                 Color
  91.             );
  92.             SetPixel(
  93.                 (HDC)HWND_DESKTOP,
  94.                 (BaseX + ((CrossHair_Variables::Size - 1) / 2)),
  95.                 (BaseY + Index),
  96.                 Color
  97.             );
  98.         };
  99.         Sleep(5);
  100.     };
  101. };
  102.  
  103. And here is the original source (credits @SMOKe and @Hell_Demon // MPGH.NET):
  104. #include <windows.h>
  105. #include <iostream>
  106. #include <math.h>
  107. using namespace std;
  108.  
  109. bool crosshairon=false;
  110. HDC ragedc = NULL;
  111. int crosshairsize=0;
  112. int cx=0;
  113. int cy=0;
  114.  
  115. void CrossThread(void)
  116. {
  117.     while(1)
  118.     {
  119.         if(GetAsyncKeyState(VK_NUMPAD0)&1)
  120.         {
  121.             crosshairon=!crosshairon;
  122.             ragedc = GetDC(HWND_DESKTOP);
  123.             cx=GetSystemMetrics(SM_CXSCREEN)/2-((crosshairsize-1)/2);
  124.             cy=GetSystemMetrics(SM_CYSCREEN)/2-((crosshairsize-1)/2);
  125.         }
  126.         Sleep(1);
  127.     }
  128. }
  129.  
  130. int main()
  131. {
  132.     cout<<"Crosshair size in pixels:\n";
  133.     cin>>crosshairsize;
  134.     if(crosshairsize%2==0) //check if its even
  135.     {
  136.         crosshairsize+=1; //if it is add 1
  137.     }
  138.     system("cls"); // clear the console :)
  139.     cout<<"Press numpad0 to toggle the crosshair on and off\n";
  140.     CreateThread(0,0,(LPTHREAD_START_ROUTINE)CrossThread,0,0,0);
  141.     while(1)
  142.     {
  143.         if(crosshairon==true)
  144.         {
  145.             for(int i=0;i<crosshairsize;i++)
  146.             {
  147.                 SetPixel(ragedc, cx+i, cy+((crosshairsize-1)/2), RGB(255,0,0));
  148.                 SetPixel(ragedc, cx+((crosshairsize-1)/2), cy+i, RGB(255,0,0));
  149.             }
  150.         }
  151.         Sleep(1);
  152.     }
  153. }
  154.  
  155. For some reason their code works, mine doesn't, any ideas?
Advertisement
Add Comment
Please, Sign In to add comment