Beispiel #1
0
void InternalAccessRemoveAll()
{
	if(!InternalAccessArray)return;
	AccessArrayMutex.Wait();
	for(int i=InternalAccessArray->GetUpperBound();i>=0;i--)
	{
		AccessArrayMutex.Release();
		InternalAccessRemoveAt(i);
		AccessArrayMutex.Wait();
	}
	AccessArrayMutex.Release();
}
Beispiel #2
0
static int InternalAccessRemoveAt(int i)
{
	int r=-1;
	char* buf;
	AccessArrayMutex.Wait();
	if(!InternalAccessArray || InternalAccessArray->GetUpperBound()<i )goto ret;
	buf=(char*)InternalAccessArray->GetAt(i);
	InternalAccessArray->RemoveAt(i);
	if(buf)
	{
#if NTVERSION>=400
		const char* np=buf+4;
		if(!strncmp(np,"\\??\\",4))
			np+=4;

#if GATEKEEPER_API_VERSION!=0x0100
		_FSRemoveInternalAccess((PCHAR)np);
#else
		_FSRemoveInternalAccess((PUCHAR)np);
#endif

#endif
		delete buf;
		r=i;
	}
ret:
	AccessArrayMutex.Release();
	return r;
}
Beispiel #3
0
int InternalAccessAdd(const char* name)
{
	if(!InternalAccessArray || name==NULL) return -1;
	char* newbuf=new char[strlen(name)+5];
	if(newbuf==NULL)return -1;
	*(DWORD*)newbuf=-1;
	strcpy(newbuf+4,name);

	char* np=newbuf+4;
	if(!strncmp(np,"\\??\\",4))
		np+=4;

#if NTVERSION>=400

#if GATEKEEPER_API_VERSION!=0x0100
	_FSAllowInternalAccess(np);
#else
	_FSAllowInternalAccess((PUCHAR)np);
#endif

#endif

	AccessArrayMutex.Wait();
	int r=InternalAccessArray->Add(newbuf);
	AccessArrayMutex.Release();

	return r;
}
Beispiel #4
0
BOOL InternalAccessInit()
{
#if NTVERSION>=400
	if(InternalAccessArray)return TRUE;
	AccessArrayMutex.Wait();
	InternalAccessArray=new CPtrArray;
	AccessArrayMutex.Release();
#endif
	return !!InternalAccessArray;
}
Beispiel #5
0
void InternalAccessDestroy()
{
	InternalAccessRemoveAll();
	AccessArrayMutex.Wait();
	if(InternalAccessArray){
		delete InternalAccessArray;
		InternalAccessArray=0;
	}
	AccessArrayMutex.Release();
}
Beispiel #6
0
static int InternalAccessHandleSetAt(int i, DWORD handle)
{
	int r=-1;
	char* buf;
	AccessArrayMutex.Wait();
	if(!InternalAccessArray || InternalAccessArray->GetUpperBound()<i ) goto ret;
	buf=(char*)InternalAccessArray->GetAt(i);
	if(buf==NULL) goto ret;
	*(DWORD*)buf=handle;
	r=i;
ret:
	AccessArrayMutex.Release();
	return i;
}
Beispiel #7
0
static int InternalAccessRemove(DWORD handle)
{
	if(!InternalAccessArray)return -1;
	AccessArrayMutex.Wait();
	for(int i=InternalAccessArray->GetUpperBound();i>=0;i--)
	{
		char* buf=(char*)InternalAccessArray->GetAt(i);
		if(buf && *(DWORD*)buf==handle)
		{
			AccessArrayMutex.Release();
			return InternalAccessRemoveAt(i);
		}
	}
	AccessArrayMutex.Release();
	return -1;
}