-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/#38-implementDokanIOSecurityContext' into develop
closes #38
- Loading branch information
Showing
8 changed files
with
170 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/main/java/dev/dokan/dokan_java/structure/DokanAccessState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package dev.dokan.dokan_java.structure; | ||
|
||
|
||
import com.sun.jna.Pointer; | ||
import com.sun.jna.Structure; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* This is a Dokan specific implementation of the ACCESS_STATE structure of the windows kernel. | ||
* | ||
* @see <a href="https://docs.microsoft.com/de-de/windows-hardware/drivers/ddi/wdm/ns-wdm-_access_state">Microsoft Documentation</a> | ||
* @see <a href="https://github.com/dokan-dev/dokany/blob/master/sys/public.h>Definition in {@code public.h}</a> of the Dokany project. | ||
*/ | ||
public class DokanAccessState extends Structure { | ||
|
||
/** | ||
* A boolean value that specifies whether security was evaluated as part of the access check. | ||
* This member is currently unused by drivers. | ||
*/ | ||
public boolean SecurityEvaluated; | ||
|
||
/** | ||
* A Boolean value that specifies whether the access should generate an audit. | ||
* This member is currently unused by drivers. | ||
*/ | ||
public boolean GenerateAudit; | ||
|
||
/** | ||
* A Boolean value that specifies whether an audit should be generated when the handle being created is closed. | ||
* This member is currently unused by drivers. | ||
*/ | ||
public boolean GenerateOnClose; | ||
|
||
/** | ||
* A Boolean value that specifies whether a privilege usage should be audited. | ||
* This member is currently unused by drivers. | ||
*/ | ||
public boolean AuditPrivileges; | ||
|
||
/** | ||
* A 32-bit value that contains bit-field flags for the access. | ||
* A driver can check for the traverse access flag (TOKEN_HAS_TRAVERSE_PRIVILEGE). | ||
* For more information about how to check for traverse access, see <a href="https://docs.microsoft.com/windows-hardware/drivers/ifs/checking-for-traverse-privilege-on-irp-mj-create">Check for Traverse Privilege on IRP_MJ_CREATE</a>. | ||
* A driver can also check for the TOKEN_IS_RESTRICTED flag. | ||
* These flags are defined in Ntifs.h. | ||
*/ | ||
public int Flags; | ||
|
||
/** | ||
* An ACCESS_MASK type that describes the access rights that have not yet been granted to the caller. | ||
* A driver uses this member to determine if the Windows security system can grant access. | ||
* If access can be granted, the driver updates the PreviouslyGrantedAccess and RemainingDesiredAccess members accordingly. | ||
*/ | ||
public int RemainingDesiredAccess; | ||
|
||
/** | ||
* An ACCESS_MASK type that specifies the information about access that has already been granted to the caller of one of the <a href="https://docs.microsoft.com/previous-versions/windows/hardware/drivers/ff563711(v=vs.85)">Security Reference Monitor Routines</a> | ||
* The Windows security system grants certain rights based on the privileges of the caller, such as traverse right (the ability to traverse through a directory as part of opening a subdirectory or file). | ||
*/ | ||
public int PreviouslyGrantedAccess; | ||
|
||
/** | ||
* An ACCESS_MASK type that contains the original access rights that were requested by the caller. | ||
*/ | ||
public int OriginalDesiredAccess; | ||
|
||
/** | ||
* A pointer to a SECURITY_DESCRIPTOR structure that contains security information for the object that this access relates to. | ||
*/ | ||
public Pointer SecurityDescriptor; | ||
//public WinNT.SECURITY_DESCRIPTOR_RELATIVE.ByReference SecurityDescriptor; //Does not work | ||
|
||
/** | ||
* A UNICODE_STRING structure that contains the object name string for the access. This member is used for auditing. | ||
*/ | ||
public UnicodeString ObjectName; | ||
|
||
/** | ||
* A UNICODE_STRING structure that contains the object type name string for the access. This member is used for auditing. | ||
*/ | ||
public UnicodeString ObjectType; | ||
|
||
@Override | ||
protected List<String> getFieldOrder() { | ||
return Arrays.asList(new String[]{"SecurityEvaluated", | ||
"GenerateAudit", | ||
"GenerateOnClose", | ||
"AuditPrivileges", | ||
"Flags", | ||
"RemainingDesiredAccess", | ||
"PreviouslyGrantedAccess", | ||
"OriginalDesiredAccess", | ||
"SecurityDescriptor", | ||
"ObjectName", | ||
"ObjectType"}); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/dev/dokan/dokan_java/structure/DokanIOSecurityContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.dokan.dokan_java.structure; | ||
|
||
|
||
import com.sun.jna.Structure; | ||
import com.sun.jna.WString; | ||
|
||
|
||
/** | ||
* The DokanIOSecurityContext contains the Dokan specific security context of the Windows kernel create request. | ||
* It is a parameter in the {@link dev.dokan.dokan_java.DokanFileSystem#zwCreateFile(WString, DokanIOSecurityContext, int, int, int, int, int, DokanFileInfo)} function. | ||
* | ||
* @see <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_io_security_context?redirectedfrom=MSDN">Microsoft documentation</a> of the original structure | ||
* @see <a href="https://github.com/dokan-dev/dokany/blob/master/sys/public.h>Definition in {@code public.h}</a> of the Dokany project. | ||
*/ | ||
@Structure.FieldOrder({"AccessState", "DesiredAccess"}) | ||
public class DokanIOSecurityContext extends Structure implements Structure.ByReference { | ||
|
||
/** | ||
* Dokan ACCESS_STATE structure that contains the object's subject context, granted access types, and remaining desired access types. | ||
*/ | ||
public DokanAccessState AccessState; | ||
|
||
/** | ||
* An ACCESS_MASK value that expresses the access rights that are requested in the IRP_MJ_CREATE request. | ||
*/ | ||
public int DesiredAccess; | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/dev/dokan/dokan_java/structure/UnicodeString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package dev.dokan.dokan_java.structure; | ||
|
||
|
||
import com.sun.jna.Pointer; | ||
import com.sun.jna.Structure; | ||
|
||
|
||
/** | ||
* Supplemental class used to define Unicode Strings. | ||
* <p> | ||
* This class is needed to fully implement {@link DokanAccessState}. | ||
* It is defined in <a href="https://github.com/dokan-dev/dokany/blob/master/dokan/fileinfo.h">fileinfo.h</a> in the dokan module of the Dokany project. | ||
*/ | ||
@Structure.FieldOrder({"Length", "MaximumLength", "Buffer"}) | ||
public class UnicodeString extends Structure { | ||
|
||
/** | ||
* The length, in bytes, of the string stored in {@link UnicodeString#Buffer}. | ||
*/ | ||
public short Length; | ||
|
||
/** | ||
* The length, in bytes, of {@link UnicodeString#Buffer}. | ||
*/ | ||
public short MaximumLength; | ||
|
||
/** | ||
* Pointer to a buffer used to contain a string of wide characters. | ||
*/ | ||
public Pointer Buffer; | ||
|
||
} |