#include <windows.h>
#include <stdio.h>

#define MAX_BUF 1024

void GiveShutdownPrivs(void);

int main(void)
{
    GiveShutdownPrivs();	
	MoveFileEx("%windir%\\system32\\uxtheme.dll","%windir%\\system32\\uxtheme.dll.old", MOVEFILE_DELAY_UNTIL_REBOOT);
	MoveFileEx("uxtheme_modded.dll","%windir%\\system32\\uxtheme.dll", MOVEFILE_DELAY_UNTIL_REBOOT);
	printf("File moved, now we'e gonna reboot\r\n");
	getchar();
	ExitWindowsEx(EWX_REBOOT|EWX_FORCEIFHUNG, 0);
}

void GiveShutdownPrivs(void)
{
	HANDLE hToken;
    TOKEN_PRIVILEGES tkp;

    if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hToken))
    {
      if (LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Lulolwutid))
      {
        tkp.PrivilegeCount = 1;
        tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
      
        AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0);
      }else
		{
			printf("This doesn't work if you're not an admin!\r\n");
			ExitProcess(1);
		}


      CloseHandle(hToken);
    }
}
