继您在上一贴的指导
http://topic.csdn.net/u/20080801/14/6cf09d6c-4c55-4298-98c7-9309b733ae54.html
目前又碰到了一个问题,驱动在Photoshop下导入TWIAN的那一层来调我DLL会OpenFileMapping失败我已经用您推荐的Process Explorer查看过。
section段的命名空间都有在。
并且,也只有Photoshop有这样的问题,试过Acdsee Fireworks Adobe ImageReady等这些AP都是成功的。
对比过成功的AP下的section段,也没有什么驱动,地址、句柄都相同。
当Photoshop通过twain那一层来调失败后,我再用相同的名字CreateFileMapping,居然也还会成功
感觉相似是两层互不干涉的共享内存。拿到2000、xp下,就没有这个问题了,感觉还是像似权限的问题。
把网络上所通用的权限函数再看了一下:
PVOID BuildRestrictedSD(PSECURITY_DESCRIPTOR pSD)
{
DWORD dwAclLength;
PSID psidEveryone=NULL;
PACL pDACL=NULL;
BOOL bResult=FALSE;
PACCESS_ALLOWED_ACE pACE=NULL;
SID_IDENTIFIER_AUTHORITY siaWorld=SECURITY_WORLD_SID_AUTHORITY;
SECURITY_INFORMATION si=DACL_SECURITY_INFORMATION; __try
{
// initialize the security descriptor
if (!InitializeSecurityDescriptor(pSD,SECURITY_DESCRIPTOR_REVISION))
{
printf("InitializeSecurityDescriptor() failed with error %d\n", GetLastError());
__leave;
}
// obtain a sid for the Authenticated Users Group
if (!AllocateAndInitializeSid(&siaWorld,1,
SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0,
&psidEveryone))
{
printf("AllocateAndInitializeSid() failed with error %d\n",GetLastError());
__leave;
}
// NOTE:
//
// The Authenticated Users group includes all user accounts that
// have been successfully authenticated by the system. If access
// must be restricted to a specific user or group other than
// Authenticated Users, the SID can be constructed using the
// LookupAccountSid() API based on a user or group name.
// calculate the DACL length
dwAclLength = sizeof(ACL)
// add space for Authenticated Users group ACE
+ sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD)
+ GetLengthSid(psidEveryone);
// allocate memory for the DACL
pDACL = (PACL)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,dwAclLength);
if (!pDACL)
{
printf("HeapAlloc() failed with error %d\n", GetLastError());
__leave;
}
// initialize the DACL
if (!InitializeAcl(pDACL, dwAclLength, ACL_REVISION))
{
printf("InitializeAcl() failed with error %d\n",GetLastError());
__leave;
}
// add the Authenticated Users group ACE to the DACL with
// GENERIC_READ, GENERIC_WRITE, and GENERIC_EXECUTE access
if (!AddAccessAllowedAce(pDACL,ACL_REVISION,GENERIC_ALL,psidEveryone))
{
printf("AddAccessAllowedAce() failed with error %d\n",GetLastError());
__leave;
}
// set the DACL in the security descriptor
if (!SetSecurityDescriptorDacl(pSD, TRUE, pDACL, FALSE))
{
printf("SetSecurityDescriptorDacl() failed with error %d\n",GetLastError());
__leave;
}
bResult = TRUE;
}
__finally
{
if(psidEveryone)
FreeSid(psidEveryone);
}
if(bResult == FALSE)
{
if(pDACL)
{
HeapFree(GetProcessHeap(), 0, pDACL);
} pDACL = NULL;
}
return (PVOID)pDACL;
}
也有看到在AllocateAndInitializeSid之后,有人再调用一次的。
不知道从何下手了
可能写的比较罗嗦
请帮忙看看吧
先谢过了。
http://topic.csdn.net/u/20080801/14/6cf09d6c-4c55-4298-98c7-9309b733ae54.html
目前又碰到了一个问题,驱动在Photoshop下导入TWIAN的那一层来调我DLL会OpenFileMapping失败我已经用您推荐的Process Explorer查看过。
section段的命名空间都有在。
并且,也只有Photoshop有这样的问题,试过Acdsee Fireworks Adobe ImageReady等这些AP都是成功的。
对比过成功的AP下的section段,也没有什么驱动,地址、句柄都相同。
当Photoshop通过twain那一层来调失败后,我再用相同的名字CreateFileMapping,居然也还会成功
感觉相似是两层互不干涉的共享内存。拿到2000、xp下,就没有这个问题了,感觉还是像似权限的问题。
把网络上所通用的权限函数再看了一下:
PVOID BuildRestrictedSD(PSECURITY_DESCRIPTOR pSD)
{
DWORD dwAclLength;
PSID psidEveryone=NULL;
PACL pDACL=NULL;
BOOL bResult=FALSE;
PACCESS_ALLOWED_ACE pACE=NULL;
SID_IDENTIFIER_AUTHORITY siaWorld=SECURITY_WORLD_SID_AUTHORITY;
SECURITY_INFORMATION si=DACL_SECURITY_INFORMATION; __try
{
// initialize the security descriptor
if (!InitializeSecurityDescriptor(pSD,SECURITY_DESCRIPTOR_REVISION))
{
printf("InitializeSecurityDescriptor() failed with error %d\n", GetLastError());
__leave;
}
// obtain a sid for the Authenticated Users Group
if (!AllocateAndInitializeSid(&siaWorld,1,
SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0,
&psidEveryone))
{
printf("AllocateAndInitializeSid() failed with error %d\n",GetLastError());
__leave;
}
// NOTE:
//
// The Authenticated Users group includes all user accounts that
// have been successfully authenticated by the system. If access
// must be restricted to a specific user or group other than
// Authenticated Users, the SID can be constructed using the
// LookupAccountSid() API based on a user or group name.
// calculate the DACL length
dwAclLength = sizeof(ACL)
// add space for Authenticated Users group ACE
+ sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD)
+ GetLengthSid(psidEveryone);
// allocate memory for the DACL
pDACL = (PACL)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,dwAclLength);
if (!pDACL)
{
printf("HeapAlloc() failed with error %d\n", GetLastError());
__leave;
}
// initialize the DACL
if (!InitializeAcl(pDACL, dwAclLength, ACL_REVISION))
{
printf("InitializeAcl() failed with error %d\n",GetLastError());
__leave;
}
// add the Authenticated Users group ACE to the DACL with
// GENERIC_READ, GENERIC_WRITE, and GENERIC_EXECUTE access
if (!AddAccessAllowedAce(pDACL,ACL_REVISION,GENERIC_ALL,psidEveryone))
{
printf("AddAccessAllowedAce() failed with error %d\n",GetLastError());
__leave;
}
// set the DACL in the security descriptor
if (!SetSecurityDescriptorDacl(pSD, TRUE, pDACL, FALSE))
{
printf("SetSecurityDescriptorDacl() failed with error %d\n",GetLastError());
__leave;
}
bResult = TRUE;
}
__finally
{
if(psidEveryone)
FreeSid(psidEveryone);
}
if(bResult == FALSE)
{
if(pDACL)
{
HeapFree(GetProcessHeap(), 0, pDACL);
} pDACL = NULL;
}
return (PVOID)pDACL;
}
也有看到在AllocateAndInitializeSid之后,有人再调用一次的。
不知道从何下手了
可能写的比较罗嗦
请帮忙看看吧
先谢过了。
CreateFileMapping
用您说的那个软件也看过,确实存在于svchost.exe的这个服务进程中。并且Photoshop下也是存在的,但就是打开失败。
LastError=2
昨天又自己写了一个测试程式来OpenFileMapping,也是成功的。您说的Re,我会再看一下。谢谢!
在那个OS下跑? 2003?Vista?
如果是VISTA,有可能是受UAC的影响。
尝试解决的方式有三种
1.关闭UAC
2.以明确指定管理员方式运行
3.以兼容方式运行。
vista32下,我用了其它AP,无论是双击还是用以管理员身份都能Open,而Photoshop无论以什么方式,都是不行。2003没有试过,2000、xp下的Photoshop(同一版本)也是可以的。
我真的要怀疑是不是Photoshop在vista32下的Bug了。
如果真是语言版本的差异,难道要我写mail给Microsoft吗?
...
这个就麻烦了另外你用中文版、Photoshop6 试试有没有问题,是不是Photoshop新版本的问题?
确实如您所说,是Photoshop的版本问题,6可以,7、8、9都不行,一直到今天我下了最新版的Photoshop CS3,才OK
事情只能到这样子了,无法再深入下去,结贴。