Wierd issue with x64
Posted: Wed Sep 30, 2015 8:12 pm
I have no idea what going on with this, but I think it's a bug.
Following code works and gives messagerequester with "Return 0".
But if you remove the out commented "Print(Hex(nt))" at the end it fails.
It Only happens with x64 and the structures a correct, any ideas?
Following code works and gives messagerequester with "Return 0".
But if you remove the out commented "Print(Hex(nt))" at the end it fails.
It Only happens with x64 and the structures a correct, any ideas?
Code: Select all
EnableExplicit
CompilerIf #PB_Compiler_Unicode = 0 Or #PB_Compiler_Processor = #PB_Processor_x86
MessageRequester("", "Please Set Unicode and x64 Compiler option!")
End
CompilerEndIf
Structure _IO_STATUS_BLOCK Align #PB_Structure_AlignC
StructureUnion
Status.l
Pointer.i
EndStructureUnion
Information.i
EndStructure
Structure _UNICODE_STRING Align #PB_Structure_AlignC
usLength.w
usMaximumLength.w
usBuffer.i
EndStructure
Structure _OBJECT_ATTRIBUTES Align #PB_Structure_AlignC
Length.l
RootDirectory.i
ObjectName.i
Attributes.l
SecurityDescriptor.i
SecurityQualityOfService.i
EndStructure
#FILE_CREATE = 2
#FILE_OPEN_IF = 3
#FILE_OVERWRITE_IF = 5
#FILE_NON_DIRECTORY_FILE = $40
#OBJ_CASE_INSENSITIVE = $40
#CSIDL_DESKTOPDIRECTORY = $10
Procedure.s GetSpecialFolderLocation(Value.l)
Protected Folder_ID,SpecialFolderLocation.s
If SHGetSpecialFolderLocation_(0, Value, @Folder_ID) = 0
SpecialFolderLocation = Space(#MAX_PATH)
SHGetPathFromIDList_(Folder_ID, @SpecialFolderLocation)
If SpecialFolderLocation
If Right(SpecialFolderLocation, 1) <> "\"
SpecialFolderLocation + "\"
EndIf
EndIf
CoTaskMemFree_(Folder_ID)
EndIf
ProcedureReturn SpecialFolderLocation.s
EndProcedure
Define Allo.q, hfile, io._IO_STATUS_BLOCK, ufilePath._UNICODE_STRING, sfilePath.s, obj._OBJECT_ATTRIBUTES, nt.l, sDesktop.s
sDesktop = GetSpecialFolderLocation(#CSIDL_DESKTOPDIRECTORY)
sfilePath = "\??\" + sDesktop + "testfile.txt"
RtlInitUnicodeString_(ufilePath, @sfilePath)
obj\Attributes = #OBJ_CASE_INSENSITIVE
obj\Length = SizeOf(_OBJECT_ATTRIBUTES)
obj\ObjectName = ufilePath
nt = NtCreateFile_(@hfile, #STANDARD_RIGHTS_ALL, obj, io, @Allo, #FILE_ATTRIBUTE_NORMAL, #FILE_SHARE_READ, #FILE_OVERWRITE_IF, #FILE_NON_DIRECTORY_FILE, 0, 0)
If nt = 0
NtClose_(hfile)
NtDeleteFile_(obj)
EndIf
MessageRequester("", "Return: " + Hex(nt, #PB_Long))
If 1 = 3
OpenConsole()
;Print(Hex(nt))
Input()
EndIf