The MASM Forum

General => The Workshop => Topic started by: jj2007 on November 09, 2016, 11:54:36 PM

Title: Finding hidden files
Post by: jj2007 on November 09, 2016, 11:54:36 PM
Just made scandisk of a USB stick and found to my surprise 17 hidden files in the scandisk report ::)

So I hacked together a little proggie that lists all hidden files for a given folder and its subfolders. That can be an entire drive, too - just drag either the drive icon or the folder over the exe. Here is the source:

include \masm32\MasmBasic\MasmBasic.inc      ; download (http://masm32.com/board/index.php?topic=94.0)
  Init
  GfCallback cbGetFiles
  .if CL$(?)
      Let esi=Utf8$(wCL$())
      .if Asc(Right$(esi))!="\"
            Let esi=esi+"\"
      .endif
      Let esi=esi+"*"
  .else
      Let esi=CurDir$()+"*"
  .endif
  PrintLine "Searching [", esi, "] for hidden files"
  GetFiles esi
  PrintLine Str$("\n%i hidden files found in ", eax), esi
  SortFiles
  For_ ecx=0 To eax-1      ; print the results
      PrintLine Str$(GfSize(ecx)), Tb$, GfDate$(ecx), Spc2$, GfTime$(ecx), Tb$, Files$(ecx)
  Next
  Inkey "--- hit any key ---"
  Exit
cbGetFiles:
      test edx, 127      ; file or folder counter
      .if Zero?
            Print "*"      ; console mode progress bar ;-)
      .endif
      xor ecx, ecx
      test [ebx.WIN32_FIND_DATAW].dwFileAttributes, FILE_ATTRIBUTE_HIDDEN
      .if Zero?
            sub ecx, 111      ; exclude all non-hidden files
      .endif
      ret
EndOfCode

Typical output:
22 hidden files found in \Masm32\*
475805  09.11.2016  02:11:08    \Masm32\RichMasm\Help\WIN32.GID
8628    25.10.2016  12:04:02    \Masm32\RichMasm\Help\opcodes.GID
8628    18.10.2016  15:03:13    \Masm32\RichMasm\Help\fphelp.GID
234232  03.09.2016  11:54:55    \Masm32\help\xhelp\win32.GID
8628    27.06.2016  09:17:22    \Masm32\RichMasm\Help\hlhelp.GID
16826   27.06.2016  09:17:14    \Masm32\RichMasm\Help\masmlib.GID


Full project is attached, with an option to see the saved files in your text editor - important if you want to see Unicode file names properly; the console can handle e.g. Russian if the Lucida font is set, but Asian fonts are notoriously difficult to display.
Title: Re: Finding hidden files
Post by: Magnum on November 12, 2016, 05:19:37 AM
A hidden Windows 95 configuration file, ending with a .gid extension, used by the Windows Help system. The first time you open a Windows help file, the Help system analyzes the file and creates an associated GID file that helps speed up access to help file topics. You can delete a GID file without harming your system, but Windows will automatically recreate the file next time you open the corresponding help file.

I saw gid files with XP.

Title: Re: Finding hidden files
Post by: hutch-- on November 20, 2016, 11:41:55 AM
Do you settings correctly and you can view all hidden files. As Andy has said, GID files have been with us as long as Winhelp format help files.
Title: Re: Finding hidden files
Post by: jj2007 on November 20, 2016, 12:02:21 PM
Quote from: hutch-- on November 20, 2016, 11:41:55 AM
Do you settings correctly and you can view all hidden files.

Sure. Show me the setting that displays only the hidden files 8)

Searching [C:\Program Files\*] for hidden files
*********************************************************************************************************
*********************************************************************************************************
*********************************************************************************************************
*********************************************
10 hidden files found in C:\Program Files\*
89      14.10.2011  05:09:29    C:\Program Files\Microsoft Games\Chess\desktop.ini
95      14.10.2011  05:09:29    C:\Program Files\Microsoft Games\Mahjong\desktop.ini
645     14.07.2009  07:32:31    C:\Program Files\Common Files\Microsoft Shared\Stationery\Desktop.ini
108     14.07.2009  06:57:12    C:\Program Files\Microsoft Games\Purble Place\desktop.ini
119     14.07.2009  06:57:12    C:\Program Files\Microsoft Games\SpiderSolitaire\desktop.ini
92      14.07.2009  06:57:12    C:\Program Files\Microsoft Games\Hearts\desktop.ini
101     14.07.2009  06:55:01    C:\Program Files\Microsoft Games\Solitaire\desktop.ini
98      14.07.2009  06:55:00    C:\Program Files\Microsoft Games\FreeCell\desktop.ini
174     14.07.2009  06:54:24    C:\Program Files\desktop.ini
398848  14.07.2009  03:39:53    C:\Program Files\Windows Mail\WinMail.exe


That was the tiny 64-bit folder. Here is the 32-bit result:
61 hidden files found in C:\Program Files (x86)\* (among a total of 153009 files)
Title: Re: Finding hidden files
Post by: sinsi on November 20, 2016, 03:18:28 PM
>Sure. Show me the setting that displays only the hidden files 8)

dir/ah-d/s
Title: Re: Finding hidden files
Post by: jj2007 on November 20, 2016, 08:21:43 PM
Right, you could do it from a DOS prompt :icon14:

When Hutch wrote "settings", I read "Explorer settings". Anyway, it's just a demo how to pick files programmatically from a GetFiles (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1054) stream.
Title: Re: Finding hidden files
Post by: sinsi on November 20, 2016, 08:40:52 PM
Settings
Title: Re: Finding hidden files
Post by: jj2007 on November 20, 2016, 08:44:35 PM
Sinsi, I've seen that dialog before, occasionally. Point is that you can't tell it "show me only the suspect files", let alone "highlight the 0.04% hidden files among my 153009 files in C:\Program Files (x86)".

That is why I added GfCallback (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1229) to the GetFiles (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1056) command, so that a coder can programmatically decide if a file, for whatever reason (e.g. GfSize, GfAgexxx (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1061)), should be included in the Files$() array.
Title: Re: Finding hidden files
Post by: sinsi on November 20, 2016, 08:52:06 PM
Suspect? In what way?
Title: Re: Finding hidden files
Post by: anunitu on November 20, 2016, 10:13:11 PM
I think JJ may be referring to perhaps "Dropped" files as in a File dropper "infected file" perhaps from spyware or even adwarIs that what you meant JJ?
Title: Re: Finding hidden files
Post by: jj2007 on November 21, 2016, 02:11:12 AM
Quote from: anunitu on November 20, 2016, 10:13:11 PMIs that what you meant JJ?

Indeed. There is no good reason imho why a file should hide somewhere at level 6 of C:\Program Files 8)