Small problem summary

vmware no network, you can not be bridged?

Virtual Network Editor -> Restore Default Settings

And then see whether the network protocol vmware bridg. .

Not to install the security not to reload.

-----------------------

win7 win10 often UAC pop, but also make a lot of programs can not be run automatically?

win + r -> gpedit.msc-> Calculator Configuration -> windows settings -> Security Settings -> Local Policies -> Security Options 

User Account Control: Run all administrators in Admin Approval Mode. . . Disable

User Account Control: a built-in administrator account in Admin Approval Mode. . . Disable

Restart

-----------------------------

Missing dll program in another computer running?

Depends.exe dragged into the program to find the missing dll into the same program directory and then run the program

---------------------------------

 

 


#include <stdio.h> #include <the Windows.h> // # the include <TlHelp32.h> // # the include <String> // # the include <afx.h>
#include <UserEnv.h> #include <WTSAPI32 .h> // # the include <afx.h> #pragma Comment (lib, "UserEnv.lib") # Comment the pragma (lib, "Wtsapi32.lib")
#define SLEEP_TIME interval // 5000
#define FILE_PATH "C: \\ log.txt "// file information output
BOOL = Brun to false;
of SERVICE_STATUS ServiceStatus;
SERVICE_STATUS_HANDLE hstatus;
// int WriteToLog (const char * STR);
void WINAPI the ServiceMain (int argc, char ** the argv);
void WINAPI CtrlHandler ( Request DWORD);
static HANDLE hProcess = NULL;


// break SESSION 0 isolation creates a user process incoming program path
int WriteToLog (const char * str)
{
FILE * pfile;
fopen_s(&pfile, FILE_PATH, "a+");
if (pfile == NULL)
{
return -1;
}
fprintf_s(pfile, "%s\n", str);
fclose(pfile);
return 0;
}
const char* itoa1(int val){static char result[sizeof(int) << 3 + 2];unsigned int tempval = val;if (val < 0) tempval = -val;int i = sizeof(int) << 3 + 1;do {result[i] = "0123456789"[tempval % 10];tempval /= 10; --i;} while (tempval);if (val < 0) result[i--] = '-';return &result[i + 1];}
HANDLE CreateUserProcess(char *lpszFileName){BOOL bRet = TRUE;DWORD dwSessionID = 0;HANDLE hToken = NULL;HANDLE hDuplicatedToken = NULL;LPVOID lpEnvironment = NULL;STARTUPINFO si = { 0 };PROCESS_INFORMATION pi = { 0 };si.cb = sizeof(si);
do{// 获得当前Session IDdwSessionID = ::WTSGetActiveConsoleSessionId();//LPCSTR err = _T("ERROR");


WriteToLog("sessionS");
// 获得当前Session的用户令牌if (FALSE == ::WTSQueryUserToken(dwSessionID, &hToken)){int i = GetLastError();
WriteToLog("WTSQueryUserToken");WriteToLog(itoa1(i));bRet = FALSE;return NULL;}
// 复制令牌if (FALSE == ::DuplicateTokenEx(hToken, MAXIMUM_ALLOWED, NULL,SecurityIdentification, TokenPrimary, &hDuplicatedToken)){int i = GetLastError();
WriteToLog("DuplicateTokenEx");WriteToLog(itoa1(i));bRet = FALSE;return NULL;}
// 创建用户Session环境if (FALSE == ::CreateEnvironmentBlock(&lpEnvironment,hDuplicatedToken, FALSE)){int i = GetLastError();
WriteToLog("CreateEnvironmentBlock");WriteToLog(itoa1(i));
bRet = FALSE;return NULL;}
//L"calc.exe"// execute the application in the user Session replication, create a process if (FALSE == :: CreateProcessAsUser (hDuplicatedToken , lpszFileName, NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT, lpEnvironment , NULL, & Si, & PI)) {int I = the GetLastError ();
WriteToLog ( "the CreateProcessAsUser"); WriteToLog (itoa1 (I)); bRet = FALSE; return NULL;} WriteToLog ( "sessionC");
} the while (FALSE ); // close the handle, releasing the resources if (lpEnvironment) {:: DestroyEnvironmentBlock ( lpEnvironment);} if (hDuplicatedToken) {:: hDuplicatedToken CloseHandle ();} if (hToken) {:: CloseHandle (hToken);} return pi .hProcess;}


void WINAPI the ServiceMain (int argc, char ** the argv) {WriteToLog ( "SMAIN");
servicestatus.dwServiceType = SERVICE_WIN32;
servicestatus.dwCurrentState = the SERVICE_START_PENDING;
servicestatus.dwControlsAccepted = SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_STOP; // only accept the system shut down and stop the service two control command
servicestatus.dwWin32ExitCode = 0;
servicestatus.dwServiceSpecificExitCode = 0;
servicestatus.dwCheckPoint = 0;
servicestatus.dwWaitHint = 0;
hstatus = :: RegisterServiceCtrlHandler ( "Boot", CtrlHandler);
IF (hstatus == 0) {int I = the GetLastError (); WriteToLog (itoa1 (I)); WriteToLog ( "RegisterServiceCtrlHandler failed");
return;
}
WriteToLog ( "RegisterServiceCtrlHandler Success");
// to the operating state reporting SCM
servicestatus.dwCurrentState = SERVICE_RUNNING;
IF (! the SetServiceStatus (hstatus, & ServiceStatus)) {int I = the GetLastError (); WriteToLog (itoa1 (I)); WriteToLog ( "the SetServiceStatus failed");
return;
}
// here you want to add the service to do the work I do here is to get the job currently available physical and virtual memory information
Brun = to true;

the while (Brun) {WriteToLog ( "while1");

// loop open WriteToLog ( "yunxing_a"); // WinExec ( "C: \\ Windows \\ hexin.exe", SW_MAX); char a [] = "C: \\ Windows \\ hexin.exe"; hProcess = CreateUserProcess (a ); WriteToLog ( "yunxing_b");
the WaitForSingleObject (the hProcess, of INFINITE); the CloseHandle (the hProcess); the hProcess = NULL;

Sleep (SLEEP_TIME);

}
WriteToLog ( "stopped-Service");
}
void WINAPI CtrlHandler (DWORD Request) {// stop service Switch (Request) {a SERVICE_CONTROL_STOP Case:
Brun = to false;
servicestatus.dwCurrentState = SERVICE_STOPPED;
BREAK;
Case SERVICE_CONTROL_SHUTDOWN:
Brun = to false;
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
break;
default:
break;
}
SetServiceStatus(hstatus, &servicestatus);}
int main(){

SERVICE_TABLE_ENTRY entrytable[2];
const char* constc = "boot";
char* c = nullptr;
c = const_cast<char*>(constc);

entrytable[0].lpServiceName = c;
entrytable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;
entrytable[1].lpServiceName = NULL;
entrytable[1].lpServiceProc = NULL;
StartServiceCtrlDispatcher(entrytable);return 0;
}



Guess you like

Origin www.cnblogs.com/moshuixiong/p/12174037.html