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)) {
|
||||
|
||||
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)
|
||||
converted = true;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#define MY_VERSION_BINARY 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
|
||||
#define SBIE_INSTALLER_PATH "..\\Bin\\"
|
||||
|
|
|
@ -19,7 +19,7 @@ SbieApi_DisableForceProcess=_SbieApi_DisableForceProcess@8
|
|||
SbieApi_EnumBoxes=_SbieApi_EnumBoxes@8
|
||||
SbieApi_EnumProcessEx=_SbieApi_EnumProcessEx@20
|
||||
|
||||
SbieApi_GetFileName=_SbieApi_GetFileName@12
|
||||
SbieApi_GetFileName=_SbieApi_GetFileName@16
|
||||
SbieApi_GetHomePath=_SbieApi_GetHomePath@16
|
||||
SbieApi_GetUnmountHive=_SbieApi_GetUnmountHive@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)
|
||||
{
|
||||
//extern P_GetFinalPathNameByHandle __sys_GetFinalPathNameByHandleW;
|
||||
//if (__sys_GetFinalPathNameByHandleW(FileHandle, NameBuf, NameLen, VOLUME_NAME_NT) > 0)
|
||||
// return STATUS_SUCCESS;
|
||||
//return STATUS_UNSUCCESSFUL;
|
||||
NTSTATUS status;
|
||||
|
||||
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(
|
||||
HANDLE FileHandle,
|
||||
ULONG NameLen,
|
||||
WCHAR *NameBuf)
|
||||
WCHAR *NameBuf,
|
||||
ULONG *NameLen,
|
||||
ULONG *ObjType)
|
||||
{
|
||||
NTSTATUS status;
|
||||
__declspec(align(8)) ULONG64 parms[API_NUM_ARGS];
|
||||
|
@ -958,6 +959,7 @@ _FX LONG SbieApi_GetFileName(
|
|||
args->handle.val64 = (ULONG64)(ULONG_PTR)FileHandle;
|
||||
args->name_len.val64 = (ULONG64)(ULONG_PTR)NameLen;
|
||||
args->name_buf.val64 = (ULONG64)(ULONG_PTR)NameBuf;
|
||||
args->type_buf.val64 = (ULONG64)(ULONG_PTR)ObjType;
|
||||
status = SbieApi_Ioctl(parms);
|
||||
|
||||
if (! NT_SUCCESS(status)) {
|
||||
|
|
|
@ -256,8 +256,9 @@ LONG SbieApi_RenameFile(
|
|||
SBIEAPI_EXPORT
|
||||
LONG SbieApi_GetFileName(
|
||||
HANDLE FileHandle,
|
||||
ULONG NameLen,
|
||||
WCHAR *NameBuf);
|
||||
WCHAR *NameBuf,
|
||||
ULONG *NameLen,
|
||||
ULONG *ObjType);
|
||||
|
||||
//SBIEAPI_EXPORT
|
||||
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_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 *,type_buf)
|
||||
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)
|
||||
{
|
||||
API_GET_FILE_NAME_ARGS *args = (API_GET_FILE_NAME_ARGS *)parms;
|
||||
FILE_OBJECT *object;
|
||||
void *object;
|
||||
NTSTATUS status;
|
||||
|
||||
status = ObReferenceObjectByHandle(
|
||||
args->handle.val, 0, *IoFileObjectType, 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;
|
||||
}
|
||||
}
|
||||
args->handle.val, 0, NULL, UserMode, &object, NULL);
|
||||
|
||||
if (NT_SUCCESS(status)) {
|
||||
|
||||
POOL *pool = proc ? proc->pool : Driver_Pool;
|
||||
OBJECT_NAME_INFORMATION *Name = NULL;
|
||||
ULONG NameLength, len;
|
||||
WCHAR *user;
|
||||
WCHAR *name_buf;
|
||||
ULONG *name_len;
|
||||
WCHAR *type_buf;
|
||||
|
||||
__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);
|
||||
if (*IoFileObjectType == objectType) {
|
||||
|
||||
FILE_OBJECT* fileObject = (FILE_OBJECT*)object;
|
||||
if (fileObject->DeviceObject->DeviceType != FILE_DEVICE_DISK) {
|
||||
|
||||
object2 = fileObject->DeviceObject;
|
||||
|
||||
if (fileObject->FileName.Buffer && fileObject->DeviceObject->DeviceType != FILE_DEVICE_CONSOLE) {
|
||||
|
||||
fileName_Buffer = fileObject->FileName.Buffer;
|
||||
fileName_Length = fileObject->FileName.Length;
|
||||
|
||||
if (fileObject->DeviceObject->DeviceType == FILE_DEVICE_NETWORK_FILE_SYSTEM) {
|
||||
|
||||
//
|
||||
// normal case for a file on a disk
|
||||
// strip \;Q:000000000000b09f prefix
|
||||
//
|
||||
|
||||
status = Obj_GetName(pool, object, &Name, &NameLength);
|
||||
if (fileName_Buffer[1] == L';') {
|
||||
wchar_t* ptr = wcschr(fileName_Buffer + 2, L'\\');
|
||||
if (ptr) {
|
||||
fileName_Length -= (ULONG)(ptr - fileName_Buffer);
|
||||
fileName_Buffer = ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type_buf = args->type_buf.val;
|
||||
if (type_buf) {
|
||||
|
||||
len = objectType->Name.Length + sizeof(WCHAR);
|
||||
|
||||
ProbeForWrite(type_buf, len, sizeof(WCHAR));
|
||||
|
||||
memcpy(type_buf, objectType->Name.Buffer, objectType->Name.Length);
|
||||
type_buf += objectType->Name.Length / sizeof(wchar_t);
|
||||
*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;
|
||||
// status = STATUS_OBJECT_PATH_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(status)) {
|
||||
|
||||
len = Name->Name.Length
|
||||
+ sizeof(WCHAR) * 2; // null padding
|
||||
if (len > args->name_len.val)
|
||||
len = sizeof(WCHAR);
|
||||
if (Name) {
|
||||
len += Name->Name.Length;
|
||||
if (fileName_Buffer)
|
||||
len += fileName_Length;
|
||||
}
|
||||
|
||||
ProbeForWrite(name_len, sizeof(ULONG), sizeof(ULONG));
|
||||
|
||||
if (len > *name_len)
|
||||
status = STATUS_BUFFER_TOO_SMALL;
|
||||
else {
|
||||
|
||||
user = args->name_buf.val;
|
||||
ProbeForWrite(user, len, sizeof(WCHAR));
|
||||
ProbeForWrite(name_buf, len, sizeof(WCHAR));
|
||||
|
||||
memcpy(user, Name->Name.Buffer, Name->Name.Length);
|
||||
user += Name->Name.Length / sizeof(WCHAR);
|
||||
*user = L'\0';
|
||||
if (Name) {
|
||||
memcpy(name_buf, Name->Name.Buffer, Name->Name.Length);
|
||||
name_buf += Name->Name.Length / sizeof(WCHAR);
|
||||
if (fileName_Buffer) {
|
||||
memcpy(name_buf, fileName_Buffer, fileName_Length);
|
||||
name_buf += fileName_Length / sizeof(WCHAR);
|
||||
}
|
||||
}
|
||||
*name_buf = L'\0';
|
||||
|
||||
status = STATUS_SUCCESS;
|
||||
|
||||
//DbgPrint("Result DISK: %S\n", args->name_buf.val);
|
||||
}
|
||||
//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);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
//
|
||||
// not file or not on disk
|
||||
//
|
||||
|
||||
status = Obj_GetName(
|
||||
pool, object->DeviceObject, &Name, &NameLength);
|
||||
if (NT_SUCCESS(status) && (Name == &Obj_Unnamed)) {
|
||||
Name = NULL;
|
||||
status = STATUS_OBJECT_PATH_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(status)) {
|
||||
|
||||
len = Name->Name.Length
|
||||
+ object->FileName.Length
|
||||
+ sizeof(WCHAR) * 2; // null padding
|
||||
if (len > args->name_len.val)
|
||||
status = STATUS_BUFFER_TOO_SMALL;
|
||||
else {
|
||||
|
||||
user = args->name_buf.val;
|
||||
ProbeForWrite(user, len, sizeof(WCHAR));
|
||||
|
||||
memcpy(user, Name->Name.Buffer, Name->Name.Length);
|
||||
user += Name->Name.Length / sizeof(WCHAR);
|
||||
memcpy(user, object->FileName.Buffer,
|
||||
object->FileName.Length);
|
||||
user += object->FileName.Length / sizeof(WCHAR);
|
||||
*user = L'\0';
|
||||
|
||||
status = STATUS_SUCCESS;
|
||||
|
||||
//DbgPrint("Result MISC: %S\n", args->name_buf.val);
|
||||
}
|
||||
}
|
||||
*name_len = len;
|
||||
}
|
||||
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
|
|
Loading…
Reference in New Issue