1.10.2g
This commit is contained in:
parent
cadb8da947
commit
cc471f2917
|
@ -320,7 +320,8 @@ bool CBoxFile::GetAbsolutePathForRecoveryFolder(WCHAR *buf, ULONG buf_len)
|
||||||
|
|
||||||
if (NT_SUCCESS(status)) {
|
if (NT_SUCCESS(status)) {
|
||||||
|
|
||||||
status = SbieApi_GetFileName(hFile, buf_len - 4, buf);
|
buf_len -= 4;
|
||||||
|
status = SbieApi_GetFileName(hFile, buf, &buf_len, NULL);
|
||||||
if (status == 0 && SavePath.CompareNoCase(buf) != 0)
|
if (status == 0 && SavePath.CompareNoCase(buf) != 0)
|
||||||
converted = true;
|
converted = true;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#define MY_VERSION_BINARY 5,65,2
|
#define MY_VERSION_BINARY 5,65,2
|
||||||
#define MY_VERSION_STRING "5.65.2"
|
#define MY_VERSION_STRING "5.65.2"
|
||||||
#define MY_ABI_VERSION 0x56000
|
#define MY_ABI_VERSION 0x56500
|
||||||
|
|
||||||
// These #defines are used by either Resource Compiler or NSIS installer
|
// These #defines are used by either Resource Compiler or NSIS installer
|
||||||
#define SBIE_INSTALLER_PATH "..\\Bin\\"
|
#define SBIE_INSTALLER_PATH "..\\Bin\\"
|
||||||
|
|
|
@ -19,7 +19,7 @@ SbieApi_DisableForceProcess=_SbieApi_DisableForceProcess@8
|
||||||
SbieApi_EnumBoxes=_SbieApi_EnumBoxes@8
|
SbieApi_EnumBoxes=_SbieApi_EnumBoxes@8
|
||||||
SbieApi_EnumProcessEx=_SbieApi_EnumProcessEx@20
|
SbieApi_EnumProcessEx=_SbieApi_EnumProcessEx@20
|
||||||
|
|
||||||
SbieApi_GetFileName=_SbieApi_GetFileName@12
|
SbieApi_GetFileName=_SbieApi_GetFileName@16
|
||||||
SbieApi_GetHomePath=_SbieApi_GetHomePath@16
|
SbieApi_GetHomePath=_SbieApi_GetHomePath@16
|
||||||
SbieApi_GetUnmountHive=_SbieApi_GetUnmountHive@4
|
SbieApi_GetUnmountHive=_SbieApi_GetUnmountHive@4
|
||||||
SbieApi_GetVersion=_SbieApi_GetVersion@4
|
SbieApi_GetVersion=_SbieApi_GetVersion@4
|
||||||
|
|
|
@ -798,12 +798,13 @@ _FX WCHAR *File_TranslateTempLinks_2(WCHAR *input_str, ULONG input_len)
|
||||||
|
|
||||||
_FX NTSTATUS File_GetFileName(HANDLE FileHandle, ULONG NameLen, WCHAR* NameBuf)
|
_FX NTSTATUS File_GetFileName(HANDLE FileHandle, ULONG NameLen, WCHAR* NameBuf)
|
||||||
{
|
{
|
||||||
//extern P_GetFinalPathNameByHandle __sys_GetFinalPathNameByHandleW;
|
NTSTATUS status;
|
||||||
//if (__sys_GetFinalPathNameByHandleW(FileHandle, NameBuf, NameLen, VOLUME_NAME_NT) > 0)
|
|
||||||
// return STATUS_SUCCESS;
|
|
||||||
//return STATUS_UNSUCCESSFUL;
|
|
||||||
|
|
||||||
return SbieApi_GetFileName(FileHandle, NameLen, NameBuf);
|
status = SbieApi_GetFileName(FileHandle, NameBuf, &NameLen, NULL);
|
||||||
|
|
||||||
|
if (NT_SUCCESS(status) && !*NameBuf)
|
||||||
|
status = STATUS_OBJECT_PATH_NOT_FOUND;
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -946,8 +946,9 @@ _FX LONG SbieApi_RenameFile(
|
||||||
|
|
||||||
_FX LONG SbieApi_GetFileName(
|
_FX LONG SbieApi_GetFileName(
|
||||||
HANDLE FileHandle,
|
HANDLE FileHandle,
|
||||||
ULONG NameLen,
|
WCHAR *NameBuf,
|
||||||
WCHAR *NameBuf)
|
ULONG *NameLen,
|
||||||
|
ULONG *ObjType)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
__declspec(align(8)) ULONG64 parms[API_NUM_ARGS];
|
__declspec(align(8)) ULONG64 parms[API_NUM_ARGS];
|
||||||
|
@ -958,6 +959,7 @@ _FX LONG SbieApi_GetFileName(
|
||||||
args->handle.val64 = (ULONG64)(ULONG_PTR)FileHandle;
|
args->handle.val64 = (ULONG64)(ULONG_PTR)FileHandle;
|
||||||
args->name_len.val64 = (ULONG64)(ULONG_PTR)NameLen;
|
args->name_len.val64 = (ULONG64)(ULONG_PTR)NameLen;
|
||||||
args->name_buf.val64 = (ULONG64)(ULONG_PTR)NameBuf;
|
args->name_buf.val64 = (ULONG64)(ULONG_PTR)NameBuf;
|
||||||
|
args->type_buf.val64 = (ULONG64)(ULONG_PTR)ObjType;
|
||||||
status = SbieApi_Ioctl(parms);
|
status = SbieApi_Ioctl(parms);
|
||||||
|
|
||||||
if (! NT_SUCCESS(status)) {
|
if (! NT_SUCCESS(status)) {
|
||||||
|
|
|
@ -256,8 +256,9 @@ LONG SbieApi_RenameFile(
|
||||||
SBIEAPI_EXPORT
|
SBIEAPI_EXPORT
|
||||||
LONG SbieApi_GetFileName(
|
LONG SbieApi_GetFileName(
|
||||||
HANDLE FileHandle,
|
HANDLE FileHandle,
|
||||||
ULONG NameLen,
|
WCHAR *NameBuf,
|
||||||
WCHAR *NameBuf);
|
ULONG *NameLen,
|
||||||
|
ULONG *ObjType);
|
||||||
|
|
||||||
//SBIEAPI_EXPORT
|
//SBIEAPI_EXPORT
|
||||||
LONG SbieApi_OpenFile(
|
LONG SbieApi_OpenFile(
|
||||||
|
|
|
@ -368,8 +368,9 @@ API_ARGS_CLOSE(API_GET_UNMOUNT_HIVE_ARGS)
|
||||||
|
|
||||||
API_ARGS_BEGIN(API_GET_FILE_NAME_ARGS)
|
API_ARGS_BEGIN(API_GET_FILE_NAME_ARGS)
|
||||||
API_ARGS_FIELD(HANDLE,handle)
|
API_ARGS_FIELD(HANDLE,handle)
|
||||||
API_ARGS_FIELD(ULONG,name_len)
|
API_ARGS_FIELD(ULONG *,name_len)
|
||||||
API_ARGS_FIELD(WCHAR *,name_buf)
|
API_ARGS_FIELD(WCHAR *,name_buf)
|
||||||
|
API_ARGS_FIELD(WCHAR *,type_buf)
|
||||||
API_ARGS_CLOSE(API_GET_FILE_NAME_ARGS)
|
API_ARGS_CLOSE(API_GET_FILE_NAME_ARGS)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2127,107 +2127,115 @@ _FX NTSTATUS File_Api_Rename(PROCESS *proc, ULONG64 *parms)
|
||||||
_FX NTSTATUS File_Api_GetName(PROCESS *proc, ULONG64 *parms)
|
_FX NTSTATUS File_Api_GetName(PROCESS *proc, ULONG64 *parms)
|
||||||
{
|
{
|
||||||
API_GET_FILE_NAME_ARGS *args = (API_GET_FILE_NAME_ARGS *)parms;
|
API_GET_FILE_NAME_ARGS *args = (API_GET_FILE_NAME_ARGS *)parms;
|
||||||
FILE_OBJECT *object;
|
void *object;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
status = ObReferenceObjectByHandle(
|
status = ObReferenceObjectByHandle(
|
||||||
args->handle.val, 0, *IoFileObjectType, UserMode, &object, NULL);
|
args->handle.val, 0, NULL, UserMode, &object, NULL);
|
||||||
|
|
||||||
if (NT_SUCCESS(status)) {
|
|
||||||
|
|
||||||
/*DbgPrint("Handle %08X DeviceObject %08X (Type %08X) ObjectName=<%*.*S>\n",
|
|
||||||
args->handle.val, object->DeviceObject,
|
|
||||||
object->DeviceObject ? object->DeviceObject->DeviceType : -1,
|
|
||||||
object->FileName.Length / sizeof(WCHAR), object->FileName.Length / sizeof(WCHAR), object->FileName.Buffer);*/
|
|
||||||
|
|
||||||
if ( (! object->DeviceObject)
|
|
||||||
|| (! object->FileName.Length)
|
|
||||||
|| (! object->FileName.Buffer)) {
|
|
||||||
|
|
||||||
ObDereferenceObject(object);
|
|
||||||
status = STATUS_BAD_DEVICE_TYPE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NT_SUCCESS(status)) {
|
if (NT_SUCCESS(status)) {
|
||||||
|
|
||||||
POOL *pool = proc ? proc->pool : Driver_Pool;
|
POOL *pool = proc ? proc->pool : Driver_Pool;
|
||||||
OBJECT_NAME_INFORMATION *Name = NULL;
|
OBJECT_NAME_INFORMATION *Name = NULL;
|
||||||
ULONG NameLength, len;
|
ULONG NameLength, len;
|
||||||
WCHAR *user;
|
WCHAR *name_buf;
|
||||||
|
ULONG *name_len;
|
||||||
|
WCHAR *type_buf;
|
||||||
|
|
||||||
__try {
|
__try {
|
||||||
|
|
||||||
if (object->DeviceObject->DeviceType == FILE_DEVICE_DISK) {
|
void *object2 = object;
|
||||||
|
wchar_t* fileName_Buffer = NULL;
|
||||||
|
ULONG fileName_Length = 0;
|
||||||
|
|
||||||
//
|
POBJECT_TYPE objectType = pObGetObjectType(object);
|
||||||
// normal case for a file on a disk
|
if (*IoFileObjectType == objectType) {
|
||||||
//
|
|
||||||
|
|
||||||
status = Obj_GetName(pool, object, &Name, &NameLength);
|
FILE_OBJECT* fileObject = (FILE_OBJECT*)object;
|
||||||
if (NT_SUCCESS(status) && (Name == &Obj_Unnamed)) {
|
if (fileObject->DeviceObject->DeviceType != FILE_DEVICE_DISK) {
|
||||||
Name = NULL;
|
|
||||||
status = STATUS_OBJECT_PATH_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NT_SUCCESS(status)) {
|
object2 = fileObject->DeviceObject;
|
||||||
|
|
||||||
len = Name->Name.Length
|
if (fileObject->FileName.Buffer && fileObject->DeviceObject->DeviceType != FILE_DEVICE_CONSOLE) {
|
||||||
+ sizeof(WCHAR) * 2; // null padding
|
|
||||||
if (len > args->name_len.val)
|
|
||||||
status = STATUS_BUFFER_TOO_SMALL;
|
|
||||||
else {
|
|
||||||
|
|
||||||
user = args->name_buf.val;
|
fileName_Buffer = fileObject->FileName.Buffer;
|
||||||
ProbeForWrite(user, len, sizeof(WCHAR));
|
fileName_Length = fileObject->FileName.Length;
|
||||||
|
|
||||||
memcpy(user, Name->Name.Buffer, Name->Name.Length);
|
if (fileObject->DeviceObject->DeviceType == FILE_DEVICE_NETWORK_FILE_SYSTEM) {
|
||||||
user += Name->Name.Length / sizeof(WCHAR);
|
|
||||||
*user = L'\0';
|
|
||||||
|
|
||||||
status = STATUS_SUCCESS;
|
//
|
||||||
|
// strip \;Q:000000000000b09f prefix
|
||||||
|
//
|
||||||
|
|
||||||
//DbgPrint("Result DISK: %S\n", args->name_buf.val);
|
if (fileName_Buffer[1] == L';') {
|
||||||
|
wchar_t* ptr = wcschr(fileName_Buffer + 2, L'\\');
|
||||||
|
if (ptr) {
|
||||||
|
fileName_Length -= (ULONG)(ptr - fileName_Buffer);
|
||||||
|
fileName_Buffer = ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
type_buf = args->type_buf.val;
|
||||||
|
if (type_buf) {
|
||||||
|
|
||||||
//
|
len = objectType->Name.Length + sizeof(WCHAR);
|
||||||
// not file or not on disk
|
|
||||||
//
|
|
||||||
|
|
||||||
status = Obj_GetName(
|
ProbeForWrite(type_buf, len, sizeof(WCHAR));
|
||||||
pool, object->DeviceObject, &Name, &NameLength);
|
|
||||||
if (NT_SUCCESS(status) && (Name == &Obj_Unnamed)) {
|
memcpy(type_buf, objectType->Name.Buffer, objectType->Name.Length);
|
||||||
Name = NULL;
|
type_buf += objectType->Name.Length / sizeof(wchar_t);
|
||||||
status = STATUS_OBJECT_PATH_NOT_FOUND;
|
*type_buf = L'\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
name_buf = args->name_buf.val;
|
||||||
|
name_len = args->name_len.val;
|
||||||
|
if (!name_buf || !name_len)
|
||||||
|
__leave;
|
||||||
|
|
||||||
|
status = Obj_GetName(pool, object2, &Name, &NameLength);
|
||||||
|
if (NT_SUCCESS(status) && (Name == &Obj_Unnamed)) {
|
||||||
|
Name = NULL;
|
||||||
|
// status = STATUS_OBJECT_PATH_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NT_SUCCESS(status)) {
|
||||||
|
|
||||||
|
len = sizeof(WCHAR);
|
||||||
|
if (Name) {
|
||||||
|
len += Name->Name.Length;
|
||||||
|
if (fileName_Buffer)
|
||||||
|
len += fileName_Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NT_SUCCESS(status)) {
|
ProbeForWrite(name_len, sizeof(ULONG), sizeof(ULONG));
|
||||||
|
|
||||||
len = Name->Name.Length
|
if (len > *name_len)
|
||||||
+ object->FileName.Length
|
status = STATUS_BUFFER_TOO_SMALL;
|
||||||
+ sizeof(WCHAR) * 2; // null padding
|
else {
|
||||||
if (len > args->name_len.val)
|
|
||||||
status = STATUS_BUFFER_TOO_SMALL;
|
|
||||||
else {
|
|
||||||
|
|
||||||
user = args->name_buf.val;
|
ProbeForWrite(name_buf, len, sizeof(WCHAR));
|
||||||
ProbeForWrite(user, len, sizeof(WCHAR));
|
|
||||||
|
|
||||||
memcpy(user, Name->Name.Buffer, Name->Name.Length);
|
if (Name) {
|
||||||
user += Name->Name.Length / sizeof(WCHAR);
|
memcpy(name_buf, Name->Name.Buffer, Name->Name.Length);
|
||||||
memcpy(user, object->FileName.Buffer,
|
name_buf += Name->Name.Length / sizeof(WCHAR);
|
||||||
object->FileName.Length);
|
if (fileName_Buffer) {
|
||||||
user += object->FileName.Length / sizeof(WCHAR);
|
memcpy(name_buf, fileName_Buffer, fileName_Length);
|
||||||
*user = L'\0';
|
name_buf += fileName_Length / sizeof(WCHAR);
|
||||||
|
}
|
||||||
status = STATUS_SUCCESS;
|
|
||||||
|
|
||||||
//DbgPrint("Result MISC: %S\n", args->name_buf.val);
|
|
||||||
}
|
}
|
||||||
|
*name_buf = L'\0';
|
||||||
|
|
||||||
|
status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
//DbgPrint("Result %d: %S\n", object->DeviceObject->DeviceType, name_buf);
|
||||||
|
//DbgPrint("Result %d: %S | %S\n", object->DeviceObject->DeviceType, Name->Name.Buffer, object->FileName.Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*name_len = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||||
|
|
Loading…
Reference in New Issue