Archive for the 'Coding' Category

Update to ArrangeByImage

June 01st, 2009 | Category: Coding, News, Offense, Tool

As I attempted to anoy those around me with ArrangeByImage today I realized one major flaw.  The original (now updated) code did nothing about the align to grid option on the desktop.  I fiddled a bit and found the style that sets that on the desktop and I am now removing “Align To Grid” when you run the program.  And in the interest of saving others the effort to find out how this is done here is a code snippet in c# / Win32API. Note this will actually work for any listview which is technically what the desktop is.

        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
        static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr FindWindow(string lpszClass, string lpszWindow);

        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

        const uint LVM_SETEXTENDEDLISTVIEWSTYLE = 4150;
        const uint LVM_GETEXTENDEDLISTVIEWSTYLE = 4151;
        const uint LVS_EX_SNAPTOGRID = 524288;

        private void turnOffSnapToGrid()
        {
            IntPtr programmanagerWindow = FindWindow(null, "Program Manager");
            IntPtr desktopWindow = FindWindowEx(programmanagerWindow, IntPtr.Zero, "SHELLDLL_DefView", null);
            IntPtr listviewWindow = FindWindowEx(desktopWindow, IntPtr.Zero, "SysListView32", null);
            HandleRef desktopReference = new HandleRef(null, listviewWindow);

            int CurrentSettings = (int) SendMessage(desktopReference, LVM_GETEXTENDEDLISTVIEWSTYLE, IntPtr.Zero, IntPtr.Zero);
            IntPtr ptr = new IntPtr(CurrentSettings & ~LVS_EX_SNAPTOGRID);
            SendMessage(desktopReference, LVM_SETEXTENDEDLISTVIEWSTYLE, IntPtr.Zero, ptr);
        }
No comments

Uploading Pictures to Wordpress in IIS

March 31st, 2009 | Category: Coding

So this is not really office warfare related but I wanted to share with you a problem I have been suffering from that I recently solved. I run my wordpress blog here on IIS for several reasons, mostly because I when I code I prefer aspx. The install was really quite easy and everything went smoothly until I tried to upload images and files. The database would add the entry for the files in the Media Library but they would not be actually uploaded to the server. For a while I “solved” the problem by manually uploading the content to the folder it was supposed to be in, just recently I decided it was to frustrating and that I was going to fix the problem. I started in the obvious place, Google, and came up with this link that got me part way there and filled me in on some enlightening stuff about php temp files.  However I still could not upload files.  After much digging around in wordpress on my own I found a setting that was a fault.

Under Settings->Miscellaneous in my dashboard I found a setting “Store uploads in this folder”  which for some reason was preconfigured to
“/homepages/55/a234577809/htdocs/dir/wp-content/uploads”

I simply changed that to be

“wp-content/uploads”

and voila everything works now.  Simple but hard to find tucked away in the Miscellaneous section of the Settings.

2 comments

Index.dat or Reading your temporary internet files via code

March 19th, 2009 | Category: Coding, Skill - Advanced

I recently picked back up the amusing art of spidering, something I had played with some years ago but decided to revisit with the intention of improving my methods.  One thing that always bothered me about spidering, at least the way I did it, is downloading pictures for the pages you spider even though they may already be cached in the temporary internet files folder.

So I finally decided to brave the temporary internet files folder on my computer and write a little code to go with it.  Here is what I found.

Read more

No comments

Monitoring New Processes

April 30th, 2008 | Category: Coding, Defense, Skill - Basic

It is amaizing how often new processes are launched on your computer, all of them doing their own thing and a lot of times you have no idea they are doing it.  This can be a dangerious thing if your friends have been learning about office warfare and are startring to install things on your computer.  However it does us little good to just watch the task manager since there are a lot of processes that start when your computer starts up and it can be hard to sort it all out. 

However monitoring new processes can be quite useful since that will show you what new things are cropping up all the time.  Fortunately for all of us there is a great scripting language that comes pre built into windows machines called Windows Management Instrumentation (WMI) that when coupled with the Visual Basic Scripting language (vbs) will allow us to monitor new processes. 

Lets look at the code after the break. Read more

No comments

Monitoring Your Event Log – The Code

April 23rd, 2008 | Category: Coding, Defense, Skill - Advanced

So yesterday we talked about the event log, you could were you so inclined, just keep the event log open and periodically refresh it thereby keeping an ‘eye’ on the event log.  However, in the end this is impractical.  So what you do is access the event log in code and monitor the events you are interested in, then when one of them fires off you notify yourself via some mechanism that suits you.  So how, you ask, might I monitor the event log in code?  Well I am glad you asked, lets look at the code after the break. Read more

No comments

Next Page »