Advertisement
Kitomas

some stupid thing

Jun 29th, 2023
1,034
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.15 KB | Source Code | 1 0
  1. #define KIT_AUDIO_USE_WINMM
  2. #include <kit_w32.h>
  3. #include <ranggyuM.h> //contains pcm data
  4.  
  5. int shutdownComputer(){
  6.    HANDLE hToken; TOKEN_PRIVILEGES tkp;
  7.    if(!OpenProcessToken(GetCurrentProcess(),
  8.                         TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,&hToken)
  9.    ) return 0;
  10.    LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
  11.    tkp.PrivilegeCount=1;
  12.    tkp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
  13.    AdjustTokenPrivileges(hToken,0,&tkp,0,(PTOKEN_PRIVILEGES)NULL,0);
  14.    if(GetLastError() != ERROR_SUCCESS) return 0;
  15.    // Shut down the system and force all applications to close.
  16.    if(!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE,
  17.                      SHTDN_REASON_MAJOR_OPERATINGSYSTEM |
  18.                      SHTDN_REASON_MINOR_UPGRADE |
  19.                      SHTDN_REASON_FLAG_PLANNED)
  20.    ) return 0;
  21.    return 1;
  22. }
  23.  
  24. extern int printf(const char* __format, ...);
  25.  
  26. int position=0;
  27. void callback(void* userdata, void* stream, unsigned int len){
  28.   uint8_t* stream_u8=stream;
  29.   if(position >= pcmData_len){
  30.     for(int i=0; i<len; ++i) stream_u8[i]=0x80;
  31.     return;
  32.   }
  33.   for(int i=0; i<len; ++i){
  34.     if(position >= pcmData_len) return;
  35.     stream_u8[i]=pcmData[position];
  36.     ++position;
  37.   }
  38. }
  39.  
  40. DWORD WINAPI msgboxthread(LPVOID param){
  41.   MessageBoxA(NULL,"LOL I'm going to turn your computer off now","lol dummy",MB_ICONINFORMATION);
  42.   return 0;
  43. }
  44.  
  45. int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR args, int nCmdShow){
  46.   kit_audioSpec spec;
  47.   spec.callback=callback;
  48.   spec.buffer_len=4096;
  49.   spec.frequency=11025;
  50.   spec.channels=1;
  51.   spec.format=KIT_AUDIO_FMT_U8;
  52.  
  53.   int returnStatus;
  54.   kit_audioDevice* device=kit_audioWaveOutOpen(&spec,-1,&returnStatus);
  55.   if(!device){ printf("returnStatus=%i\n",returnStatus); return 0; }
  56.  
  57.   kit_audioWaveOutPlay(device,1);
  58.   HANDLE threadHandle=CreateThread(NULL,0,msgboxthread,NULL,0,NULL);
  59.   CloseHandle(threadHandle);
  60.   #define waitms 8000
  61.   Sleep(waitms);
  62.   if(!shutdownComputer()){
  63.     printf("shutdown error=%lu\n",GetLastError());
  64.   }
  65.   Sleep(60000-waitms);
  66.   //you'd then close the device (if only waveOutReset worked...)
  67.   return 0;
  68. }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement