Click here to Skip to main content
15,887,399 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: help me !! Pin
Mohammadj9-May-09 8:55
Mohammadj9-May-09 8:55 
GeneralRe: help me !! Pin
Mohammadj10-May-09 23:38
Mohammadj10-May-09 23:38 
Questionneed a program on theory of computation Pin
krsrinivas2-May-09 7:25
krsrinivas2-May-09 7:25 
QuestionRe: need a program on theory of computation Pin
David Crow2-May-09 14:52
David Crow2-May-09 14:52 
GeneralRe: need a program on theory of computation Pin
krsrinivas2-May-09 19:46
krsrinivas2-May-09 19:46 
GeneralRe: need a program on theory of computation Pin
killabyte2-May-09 21:55
killabyte2-May-09 21:55 
GeneralRe: need a program on theory of computation Pin
Cedric Moonen2-May-09 22:18
Cedric Moonen2-May-09 22:18 
QuestionACL+LOCAL_MACHINE [modified] Pin
steph42-May-09 7:19
steph42-May-09 7:19 
Hello!
I'm trying to get ACL from HKEY_LOCAL_MACHINE (also such problem with HKEY_CURRENT_CONFIG) registry key.
#include <iostream>
#include <conio.h>
#include <sddl.h>
#include <Aclapi.h>
#include<string.h>
#include <strsafe.h>
#include <windows.h>
char information[1024];
int My_GetObjectAcl(int qtype,char *filestr){
	int i,j;
	char sd[4096];
	char temp1[256];
	DWORD sdsize;
	char strnew[4096];
	DWORD sdnewlen=0; DWORD count;
	PEXPLICIT_ACCESS pList[10]; 
	BOOL d1,d2;
	PACL pDacl=NULL;
	DWORD aclSize;
	BYTE bACEType;
	LPVOID pAce;
	LPBOOL bbb=0;
	PSID pSID=NULL;
	PSID osid=NULL;
	SID_NAME_USE SidType;
	ACCESS_ALLOWED_ACE *ACE;
	DWORD tmp;
	SE_OBJECT_TYPE otype;
	char Name[100], Domain[100];
	DWORD NameSize = 100, DomainSize = 100;
	LPSTR *sidstring;
	char str1[512], str2[512];
	memset(temp1,0,256);
	switch (qtype){
		case 1: otype=SE_FILE_OBJECT; break;
		case 2: otype=SE_REGISTRY_KEY; break;
		default: return 5;
	}
	printf("Trying read: %s\n",filestr);
	pDacl=(PACL)GlobalAlloc(GMEM_FIXED,1000);
	if (qtype==1){
		if (!GetFileSecurityA((LPCSTR)filestr,DACL_SECURITY_INFORMATION,sd,4096,&sdsize)) {printf("Error %d\n",GetLastError());return 5;}
	i=GetSecurityDescriptorDacl(sd,&d1,&pDacl,&d2);
	if (!i){ printf("Error %d\n",GetLastError());return 5;}
	} else
		if(GetNamedSecurityInfoA((LPSTR)filestr,otype,DACL_SECURITY_INFORMATION,NULL,NULL,&pDacl,NULL,NULL)!=ERROR_SUCCESS){printf("::%d",qtype); return 5;}

memset(temp1,0,256);
	sprintf(temp1,"Number of ace entries: %d \n",pDacl->AceCount);
	strcat(information,temp1);
	for (i=0;i<pDacl->AceCount;i++){
		memset(str1,'\0',512);
		j=0;
		NameSize = 100; DomainSize = 100;
		GetAce(pDacl,i,&pAce);
		bACEType = ((ACE_HEADER*)pAce)->AceType;
		ACE = ((ACCESS_ALLOWED_ACE *)pAce);
		pSID = (PSID)&(ACE->SidStart);
		j=LookupAccountSidA(NULL,pSID,Name,&NameSize,Domain, &DomainSize,&SidType);
		if (j==0) printf("\n\n%lu\n\n",GetLastError());				
		
		strcpy(str1,Domain);
		strcat(str1,"\\");
		strcat(str1,Name);
		CharToOemA(Name,Name);
		memset(temp1,0,256);
		sprintf(temp1,"%s\\%s: \n",Domain,Name);
		strcat(information,temp1);
		switch(bACEType){
			case ACCESS_ALLOWED_ACE_TYPE:memset(temp1,0,256);sprintf(temp1,"%s","TYPE:ALLOWED   ");strcat(information,temp1);break;
			case ACCESS_DENIED_ACE_TYPE:memset(temp1,0,256);sprintf(temp1,"%s","TYPE:DENIED  ");strcat(information,temp1);  break;
		}
		memset(temp1,0,256);
		 sprintf(temp1,"Mask: %X\n",ACE->Mask);
		 strcat(information,temp1); 
		 	memset(temp1,0,256);
		 tmp=0x80000000;
		 for (j=0;j<32;j++){
			 if ((ACE->Mask)&tmp) strcat(temp1,"1"); else    strcat(temp1,"0");
			 tmp=tmp>>1;
		 }
		strcat(information,temp1);
	}
		return 0;
}
int main()
{int k;
k=My_GetObjectAcl(2,"CURRENT_USER\\");
printf("%s\n",information);//all fine
memset(information,0,1024);
k=My_GetObjectAcl(2,"LOCAL_MACHINE\\");
printf("%s\n",information);//nothing
getch();
}
;

With CURRENT_USER\\ , USERS\\ and CLASSES_ROOT\\ - all fine. But LOCAL_MACHINE\\ and CURRENT_CONFIG\\ - error. Cry | :(( It's really necessary to me to understand why it doesn't work. Please, help me to manage with this problem.Thank You.

modified on Sunday, May 3, 2009 5:53 AM

QuestionProblem Converting string/const char* to OLECHAR FAR* Pin
CoffeeAddict192-May-09 6:41
CoffeeAddict192-May-09 6:41 
AnswerRe: Problem Converting string/const char* to OLECHAR FAR* Pin
Code-o-mat2-May-09 8:52
Code-o-mat2-May-09 8:52 
Questiondisplay image in CListctrl Pin
AnithaSubramani2-May-09 2:10
AnithaSubramani2-May-09 2:10 
AnswerRe: display image in CListctrl Pin
Elsie2-May-09 3:15
Elsie2-May-09 3:15 
AnswerRe: display image in CListctrl Pin
Code-o-mat2-May-09 5:18
Code-o-mat2-May-09 5:18 
QuestionTIME_ZONE_INFORMATION structure Pin
Elsie2-May-09 1:39
Elsie2-May-09 1:39 
QuestionRe: TIME_ZONE_INFORMATION structure Pin
David Crow2-May-09 5:57
David Crow2-May-09 5:57 
QuestionClient_Server query. Pin
Le@rner2-May-09 1:26
Le@rner2-May-09 1:26 
Questionhow to hide a window Pin
tyr20002-May-09 0:34
tyr20002-May-09 0:34 
AnswerRe: how to hide a window Pin
Elsie2-May-09 1:47
Elsie2-May-09 1:47 
GeneralRe: how to hide a window Pin
tyr20002-May-09 2:39
tyr20002-May-09 2:39 
GeneralRe: how to hide a window Pin
Elsie2-May-09 2:43
Elsie2-May-09 2:43 
GeneralRe: how to hide a window Pin
Elsie2-May-09 3:11
Elsie2-May-09 3:11 
GeneralRe: how to hide a window Pin
tyr20003-May-09 2:01
tyr20003-May-09 2:01 
QuestionRe: how to hide a window Pin
David Crow2-May-09 5:59
David Crow2-May-09 5:59 
AnswerRe: how to hide a window Pin
tyr20003-May-09 2:00
tyr20003-May-09 2:00 
GeneralRe: how to hide a window Pin
David Crow3-May-09 15:16
David Crow3-May-09 15:16 

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.