flat assembler
Message board for the users of flat assembler.

Index > Windows > SetCurrentDirectory case insensitive

Author
Thread Post new topic Reply to topic
zxcv
Guest




zxcv 21 Dec 2007, 02:29
From a long time i have problem with this function. I know that in windows files are case insensitive, but 'cd' command wotks fine.
Code:
section '.code' code readable executable
push buff
push 256
call [GetCurrentDirectoryA]
push buff
call [puts]
push dir
call [SetCurrentDirectoryA]
push buff
push 256
call [GetCurrentDirectoryA]
push buff
call [puts]
add esp, 8
ret
section '.data' data readable writeable
buff rb 256
dir db '../DeSkTop',0    


and output is:
Code:
C:\Documents and Settings\Administrator\Desktop
C:\Documents and Settings\Administrator\DeSkTop    

If i do a cd command 'cd DesKToP', getcurrentdirectory will output real name, 'Desktop'. Why its that? How can i fix it?
Post 21 Dec 2007, 02:29
Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 21 Dec 2007, 03:14
for one, you are using 'puts'. You shouldn't use that. Second, windows is probably, (after it verifies the path) just spitting out the string you gave it. I don't think it would bother to look up the "real" name if the name you gave it works just fine. Think of it this way: If files are case-insensitive, and you were the windows designer, do you think that you would take the file path, verify it, then lookup the lower-case file name, then use that? NOOO You would just give back in the case that the user gave it. Should work just fine, if you want to check if the user has inputted a file name with any capitals, just cycle through the bytes checking for ones below 0x61. That should verify that the string has all lowercase letters
Post 21 Dec 2007, 03:14
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 21 Dec 2007, 03:43
zxcv wrote:
How can i fix it?
You could try using GetFullPathName. Just a stab in the dark here, I haven't tried it.
Post 21 Dec 2007, 03:43
View user's profile Send private message Visit poster's website Reply with quote
zxcv
Guest




zxcv 21 Dec 2007, 06:48
GetFullPathNameA same as GetCurrentCirectoryA.
in filename i gave '.'.

Why cmd.exe know how to do it? How it do it?
Post 21 Dec 2007, 06:48
Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 21 Dec 2007, 07:27
There a few file related API's. I think you just need to try them one by one to see which one gives you what you want.

FindFirstFile?
Post 21 Dec 2007, 07:27
View user's profile Send private message Visit poster's website Reply with quote
zxcv
Guest




zxcv 21 Dec 2007, 07:50
FindFirstFile works ok, but give me only 1 name (Desktop).

I hope thers another way to do that.
Post 21 Dec 2007, 07:50
Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 21 Dec 2007, 10:22
FindFirstFile will give you the "real name" of the folder. GetLongPathName() seems to work as well, but I'm not sure whether it'll fail on some windows versions when using a "long filename" as input...
Post 21 Dec 2007, 10:22
View user's profile Send private message Visit poster's website Reply with quote
zxcv
Guest




zxcv 21 Dec 2007, 12:10
yes!!
finally, thanks much!
Post 21 Dec 2007, 12:10
Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.