Click here to Skip to main content
15,897,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Public IP address Pin
User 1278214-Jun-04 17:07
User 1278214-Jun-04 17:07 
General%CPU and Memory footprint question Pin
ben214-Jun-04 10:57
ben214-Jun-04 10:57 
GeneralRe: %CPU and Memory footprint question Pin
Michael Dunn14-Jun-04 11:12
sitebuilderMichael Dunn14-Jun-04 11:12 
GeneralRe: %CPU and Memory footprint question Pin
ben214-Jun-04 11:49
ben214-Jun-04 11:49 
GeneralRe: %CPU and Memory footprint question Pin
ben214-Jun-04 14:11
ben214-Jun-04 14:11 
GeneralCDateTimeCtrl Pin
sschilachi14-Jun-04 10:29
sschilachi14-Jun-04 10:29 
GeneralRe: CDateTimeCtrl Pin
palbano14-Jun-04 11:15
palbano14-Jun-04 11:15 
General(Nt)Zw Registry calls Pin
Dan Madden14-Jun-04 9:26
Dan Madden14-Jun-04 9:26 
Hi, I created a class that uses the NtNative APIs found in the ntdll.dll. Everything works except the "Hive File" functions. Below is the "LoadKey" function:

<br />
BOOL CKey::LoadKey(CString csHiveFilePathName, ULONG ulFlags /* 0x0000 */)<br />
{<br />
<br />
	ASSERT(csHiveFilePathName != _T(""));<br />
	ASSERT((m_csRootPath == _T("\\Registry\\User") || <br />
			m_csRootPath == _T("\\Registry\\Machine")));<br />
<br />
	BOOL bSuccess = TRUE;<br />
<br />
	HANDLE hRootKey = NULL, hHiveFile = NULL;<br />
<br />
	NT::UNICODE_STRING usRootKeyName, usHiveFileName, usHiveFile;<br />
    NT::OBJECT_ATTRIBUTES DestinationKeyName, RegHiveFileName, RegHiveFile;<br />
<br />
	int n=0;<br />
<br />
<br />
	// Make sure the filenames is setup correctly<br />
	if (csHiveFilePathName.Left(4) != _T("\\??\\"))<br />
		csHiveFilePathName.Insert(0,_T("\\??\\"));<br />
<br />
	// Enable the restore privilege<br />
	m_NtStatus = EnablePrivilege(SE_RESTORE_NAME, TRUE);<br />
	if(!NT_SUCCESS(m_NtStatus))<br />
	{<br />
		bSuccess = FALSE;<br />
		goto end_it;<br />
	}<br />
<br />
	WCHAR wszHiveFile[1024];<br />
	for (n=0; n<csHiveFilePathName.GetLength(); n++)<br />
		wszHiveFile[n] = (WCHAR)csHiveFilePathName[n];<br />
<br />
	wszHiveFile[n++] = L'\0';<br />
<br />
	usHiveFileName.Buffer = wszHiveFile;<br />
	usHiveFileName.Length = wcslen(wszHiveFile) * sizeof(WCHAR);<br />
<br />
	InitializeObjectAttributes(&RegHiveFileName, &usHiveFileName, <br />
								OBJ_CASE_INSENSITIVE, NULL, NULL );<br />
<br />
	WCHAR wszRootKey[2048];<br />
	for (n=0; n<m_csRootPath.GetLength(); n++)<br />
		wszRootKey[n] = (WCHAR)m_csRootPath[n];<br />
<br />
	wszRootKey[n++] = L'\0';<br />
<br />
	usRootKeyName.Buffer = wszRootKey;<br />
	usRootKeyName.Length = wcslen(wszRootKey) * sizeof(WCHAR);<br />
<br />
	InitializeObjectAttributes(&DestinationKeyName, &usRootKeyName, <br />
								OBJ_CASE_INSENSITIVE, NULL, NULL );<br />
<br />
	if (ulFlags == 0x0000)<br />
	{<br />
		if (m_ntModeType == 0) // UserMode = 0, KernalMode = 1<br />
			m_NtStatus = NT::ZwLoadKey(&DestinationKeyName, &RegHiveFileName);<br />
		else<br />
//			m_NtStatus = NT::NtLoadKey(&DestinationKeyName, &RegHiveFileName);<br />
	}<br />
	else<br />
		m_NtStatus = NT::ZwLoadKey2(&DestinationKeyName, &RegHiveFileName, ulFlags);<br />
<br />
	if (!NT_SUCCESS(m_NtStatus)) <br />
	{<br />
		bSuccess = FALSE;<br />
	}<br />
<br />
end_it:<br />
<br />
	m_csFunction = _T("LoadKey()");<br />
	if (ulFlags == 0x0004)<br />
		m_csFunction = _T("LoadKey(2)");<br />
<br />
	if (!bSuccess) <br />
		Output(DisplayError(m_NtStatus), MB_OK|MB_ICONERROR);<br />
<br />
	// Now remove the privilege (back to its prior state).<br />
	// This is not strictly necessary, since we're going<br />
	// to terminate the process anyway, and the token we've<br />
	// adjusted will be destroyed, but in real life you might<br />
	// have processes that do a little more than this :-)<br />
	m_NtStatus = EnablePrivilege(SE_RESTORE_NAME, FALSE);<br />
<br />
//	NT::ZwClose( hRootKey );<br />
//	NT::ZwClose( hHiveFile );<br />
<br />
	if (!NT_SUCCESS(m_NtStatus)) <br />
	{<br />
		Output(DisplayError(m_NtStatus), MB_OK|MB_ICONERROR);<br />
		m_csFunction = _T("");<br />
		return FALSE;<br />
	}<br />
	else if (!bSuccess) <br />
	{<br />
		m_csFunction = _T("");<br />
		return FALSE;<br />
	}<br />
<br />
	return TRUE;<br />
}<br />



Appreciate any help you can give me!!!


Regards,

Dan
AnswerRe: How do i know when the mouse leaves an area? Pin
Maximilien14-Jun-04 8:53
Maximilien14-Jun-04 8:53 
GeneralRe: How do i know when the mouse leaves an area? Pin
kfaday14-Jun-04 9:27
kfaday14-Jun-04 9:27 
GeneralRe: How do i know when the mouse leaves an area? Pin
Maximilien14-Jun-04 9:45
Maximilien14-Jun-04 9:45 
GeneralRe: How do i know when the mouse leaves an area? Pin
kfaday14-Jun-04 10:32
kfaday14-Jun-04 10:32 
AnswerRe: How do i know when the mouse leaves an area? Pin
Johan Rosengren14-Jun-04 9:10
Johan Rosengren14-Jun-04 9:10 
AnswerRe: How do i know when the mouse leaves an area? Pin
toxcct14-Jun-04 11:23
toxcct14-Jun-04 11:23 
GeneralRe: How do i know when the mouse leaves an area? Pin
kfaday14-Jun-04 11:59
kfaday14-Jun-04 11:59 
GeneralRe: How do i know when the mouse leaves an area? Pin
toxcct14-Jun-04 20:46
toxcct14-Jun-04 20:46 
GeneralRe: How do i know when the mouse leaves an area? Pin
kfaday15-Jun-04 8:12
kfaday15-Jun-04 8:12 
GeneralRe: How do i know when the mouse leaves an area? Pin
kfaday15-Jun-04 9:19
kfaday15-Jun-04 9:19 
GeneralRe: How do i know when the mouse leaves an area? Pin
toxcct15-Jun-04 9:20
toxcct15-Jun-04 9:20 
QuestionHow do i know when the mouse leaves an area? Pin
kfaday14-Jun-04 8:46
kfaday14-Jun-04 8:46 
GeneralCreateCompatibleBitmap and mem allocation Pin
IGeorgeI14-Jun-04 8:46
IGeorgeI14-Jun-04 8:46 
GeneralRe: CreateCompatibleBitmap and mem allocation Pin
Johan Rosengren14-Jun-04 9:14
Johan Rosengren14-Jun-04 9:14 
GeneralRe: CreateCompatibleBitmap and mem allocation Pin
Vadim Tabakman14-Jun-04 16:59
Vadim Tabakman14-Jun-04 16:59 
GeneralSending small strings through sockets (lag problem) Pin
kfaday14-Jun-04 7:44
kfaday14-Jun-04 7:44 
GeneralRe: Sending small strings through sockets (lag problem) Pin
Ravi Bhavnani14-Jun-04 8:58
professionalRavi Bhavnani14-Jun-04 8:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.