#include "precomp.h"
-EXTERN_C HRESULT WINAPI SHCreateSessionKey(REGSAM samDesired, PHKEY phKey);
-
#define INVALID_RUNCMD_RETURN -1
/**
* This function runs the specified command in the specified dir.
if (!CreateProcessW(NULL, szCmdLineExp, NULL, NULL, FALSE, 0, NULL, dir, &si, &info))
{
- DbgPrint("Failed to run command (%lu)\n", GetLastError());
+ TRACE("Failed to run command (%lu)\n", GetLastError());
return INVALID_RUNCMD_RETURN;
}
- DbgPrint("Successfully ran command\n");
+ TRACE("Successfully ran command\n");
if (wait)
{ /* wait for the process to exit */
WCHAR *szValue = NULL;
if (hkRoot == HKEY_LOCAL_MACHINE)
- DbgPrint("processing %ls entries under HKLM\n", szKeyName);
+ TRACE("processing %ls entries under HKLM\n", szKeyName);
else
- DbgPrint("processing %ls entries under HKCU\n", szKeyName);
+ TRACE("processing %ls entries under HKCU\n", szKeyName);
res = RegOpenKeyExW(hkRoot,
L"Software\\Microsoft\\Windows\\CurrentVersion",
&hkWin);
if (res != ERROR_SUCCESS)
{
- DbgPrint("RegOpenKey failed on Software\\Microsoft\\Windows\\CurrentVersion (%ld)\n", res);
+ TRACE("RegOpenKey failed on Software\\Microsoft\\Windows\\CurrentVersion (%ld)\n", res);
goto end;
}
{
if (res == ERROR_FILE_NOT_FOUND)
{
- DbgPrint("Key doesn't exist - nothing to be done\n");
+ TRACE("Key doesn't exist - nothing to be done\n");
res = ERROR_SUCCESS;
}
else
- DbgPrint("RegOpenKeyEx failed on run key (%ld)\n", res);
+ TRACE("RegOpenKeyEx failed on run key (%ld)\n", res);
goto end;
}
NULL);
if (res != ERROR_SUCCESS)
{
- DbgPrint("Couldn't query key info (%ld)\n", res);
+ TRACE("Couldn't query key info (%ld)\n", res);
goto end;
}
if (i == 0)
{
- DbgPrint("No commands to execute.\n");
+ TRACE("No commands to execute.\n");
res = ERROR_SUCCESS;
goto end;
}
- szCmdLine = HeapAlloc(hProcessHeap,
+ szCmdLine = (WCHAR*)HeapAlloc(hProcessHeap,
0,
cbMaxCmdLine);
if (szCmdLine == NULL)
{
- DbgPrint("Couldn't allocate memory for the commands to be executed\n");
+ TRACE("Couldn't allocate memory for the commands to be executed\n");
res = ERROR_NOT_ENOUGH_MEMORY;
goto end;
}
++cchMaxValue;
- szValue = HeapAlloc(hProcessHeap,
+ szValue = (WCHAR*)HeapAlloc(hProcessHeap,
0,
cchMaxValue * sizeof(*szValue));
if (szValue == NULL)
{
- DbgPrint("Couldn't allocate memory for the value names\n");
+ TRACE("Couldn't allocate memory for the value names\n");
res = ERROR_NOT_ENOUGH_MEMORY;
goto end;
&cbDataLength);
if (res != ERROR_SUCCESS)
{
- DbgPrint("Couldn't read in value %lu - %ld\n", i, res);
+ TRACE("Couldn't read in value %lu - %ld\n", i, res);
continue;
}
if (bDelete && (res = RegDeleteValueW(hkRun, szValue)) != ERROR_SUCCESS)
{
- DbgPrint("Couldn't delete value - %lu, %ld. Running command anyways.\n", i, res);
+ TRACE("Couldn't delete value - %lu, %ld. Running command anyways.\n", i, res);
}
if (type != REG_SZ)
{
- DbgPrint("Incorrect type of value #%lu (%lu)\n", i, type);
+ TRACE("Incorrect type of value #%lu (%lu)\n", i, type);
continue;
}
res = runCmd(szCmdLine, NULL, bSynchronous, FALSE);
if (res == INVALID_RUNCMD_RETURN)
{
- DbgPrint("Error running cmd #%lu (%lu)\n", i, GetLastError());
+ TRACE("Error running cmd #%lu (%lu)\n", i, GetLastError());
}
- DbgPrint("Done processing cmd #%lu\n", i);
+ TRACE("Done processing cmd #%lu\n", i);
}
res = ERROR_SUCCESS;
if (hkWin != NULL)
RegCloseKey(hkWin);
- DbgPrint("done\n");
+ TRACE("done\n");
return res == ERROR_SUCCESS ? TRUE : FALSE;
}
res = GetWindowsDirectoryW(gen_path, sizeof(gen_path) / sizeof(gen_path[0]));
if (res == 0)
{
- DbgPrint("Couldn't get the windows directory - error %lu\n", GetLastError());
+ TRACE("Couldn't get the windows directory - error %lu\n", GetLastError());
return 100;
}
if (!SetCurrentDirectoryW(gen_path))
{
- DbgPrint("Cannot set the dir to %ls (%lu)\n", gen_path, GetLastError());
+ TRACE("Cannot set the dir to %ls (%lu)\n", gen_path, GetLastError());
return 100;
}
if (res && bNormalBoot && (SHRestricted(REST_NOCURRENTUSERRUNONCE) == 0))
res = ProcessRunKeys(HKEY_CURRENT_USER, L"RunOnce", TRUE, FALSE);
- DbgPrint("Operation done\n");
+ TRACE("Operation done\n");
return res ? 0 : 101;
}