ibennz

swag detector

Mar 15th, 2014
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. #include "Header.h"
  2.  
  3. int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR path, int)
  4. {
  5.  
  6.     HMODULE mod = LoadLibraryEx(path, NULL, LOAD_LIBRARY_AS_DATAFILE);
  7.  
  8.     if (!mod)
  9.     {
  10.         MessageBox(0, "Wrong Path.", "huhue", 0);
  11.     }
  12.  
  13.     HRSRC rezPtr = FindResource(mod, "69", "swag");
  14.  
  15.     if (!rezPtr)
  16.     {
  17.         if (MessageBox(0, "Resource not found, would you like to add #swag to your file ?", "huhue", MB_YESNO) == IDYES) {
  18.  
  19.         FreeLibrary(mod);
  20.  
  21.         TCHAR* data  = TEXT("#yolo");
  22.  
  23.         HANDLE rezHandle = BeginUpdateResource(path, false);
  24.  
  25.         if (!UpdateResource(rezHandle, "swag", "69", 0, data, tcslen(data)))
  26.         {
  27.             MessageBox(0, "ubrokesomeshit", "", 0);
  28.         }
  29.  
  30.         if (!EndUpdateResource(rezHandle, false))
  31.         {
  32.             MessageBox(0, "ubrokesomeshit", "", 0);
  33.         }
  34.  
  35.         }
  36.  
  37.         MessageBox(0, "Swag successfully added ! Now I must go." , "huhue", 0);
  38.         return 0;
  39.     }
  40.  
  41.     HGLOBAL f = LoadResource(mod, rezPtr);
  42.     DWORD sz = SizeofResource(mod, rezPtr);
  43.     TCHAR* resText = (TCHAR*)LockResource(f);
  44.     TCHAR* text = (TCHAR*)malloc(sz);
  45.     memcpy(text, resText, sz);
  46.     text[sz] = 0;
  47.     FreeResource(f);
  48.     FreeLibrary(mod);
  49.  
  50.     TCHAR* Prechar = TEXT("Found the swag ! :");
  51.     DWORD buff = _MAX_PATH + (tcslen(Prechar) / sizeof(TCHAR));
  52.     TCHAR* fd = (TCHAR*)malloc(buff);
  53.     tsprintf_s(fd, buff, "%s%s", Prechar , text);
  54.     MessageBox(0, fd, "huhue", 0);
  55.  
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment