Results 1 to 5 of 5

Thread: [RESOLVED] windows\system32 writes to windows\syswow64

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2007
    Posts
    22

    Resolved [RESOLVED] windows\system32 writes to windows\syswow64

    trying to write to c:\windows\system32 on a windows 7 x64 machine, but the application keeps writing to c:\windows\syswow64 instead.

    I have heard of windows interpreting commands and modifying them to be what microsoft "thinks" you are trying to do....when dealing with 32 bit apps running on a 64 bit os.... i am just not sure how to go about handling it.

    the line of code im using is:
    Code:
    System.IO.File.WriteAllBytes("C:\Windows\System32\dbcon9x64TEST.dll", My.Resources.dbcon9X64)
    the issue is I need to write files to both c:\windows\system32 and c:\windows\syswow64 ....the files need to have the same name... but they ARE different files. any help would be greatly appreciated!

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: windows\system32 writes to windows\syswow64

    Trying to write a file directly into a system folder from an external app does not smack of a virus at all.

    A quick search told me this.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2007
    Posts
    22

    Re: windows\system32 writes to windows\syswow64

    I am trying to place a driver into the system32 directory and then use it to create new ODBC drivers and DSNs..... NOT trying to write a virus.

    this application is to compliment an exist application at my office. The existing application was designed with power builder and places drivers for the ODBC connection into system32...... so my application has to be able to write and/or update the driver file stored in system32. It works with no problems in 32 bit machines, but in 64 bit operating systems windows interprets my command and places the file into the 32 bit equivalent of c:\windows\system32

  4. #4
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: windows\system32 writes to windows\syswow64

    If your application is 64bit it will use system32, if the app is 32, it will use the wow folder. Surely you either need one or the other not both. You can work out if you are using a 32 or 64 box and decide which version of the file to extract to your current system32 directory and let windows deal with it, after all, that is what it is trying to do!

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2007
    Posts
    22

    Resolved Re: windows\system32 writes to windows\syswow64

    Actually I do need both due to the poor planning of the first application. the first application actually consists of 2 apps. one is the database front end, and another is the database updater. the database front end will only ever use the 32 bit ODBC entries regardless of whether the OS is 32 or 64 bit. .... unfortunately the updater will use 64 bit odbc entries on a 64 bit os.... and 32bit odbc entries on a 32 bit os. Because the original source code to the updater application is now lost (dont get me started on that....) my mini application will be run prior to the updater running...and it will check for a 64 bit os and install the 64 bit driver and 64 bit odbc entries as well as 32 bit driver and 32 bit odbc entries, thus enabling compatability for both the database front end as well as the database updater.

    using the msdn link you posted in your first post I was able to implement the api calls to disable and re-enable the File System Redirection using the following code:

    Code:
    Public Class Form1
        Private Declare Function Wow64RevertWow64FsRedirection Lib "kernel32" (ByRef oldvalue As Long) As Boolean
        Private Declare Function Wow64DisableWow64FsRedirection Lib "kernel32" (ByRef oldvalue As Long) As Boolean
        Private lFsRedirectOldValue As Long = Nothing
    
        Private Function Add64BitOdbc() As Boolean
            Dim result As Boolean = False 'default to false
            If Environment.Is64BitOperatingSystem = True Then
                Try
                    Wow64DisableWow64FsRedirection(lFsRedirectOldValue)
                    System.IO.File.WriteAllBytes("C:\Windows\System32\dbcon9.dll", My.Resources.dbcon9X64)
                    Wow64RevertWow64FsRedirection(lFsRedirectOldValue)
                    result = True
                Catch Errors As Exception
                    MsgBox(Errors.Message)
                    Wow64RevertWow64FsRedirection(lFsRedirectOldValue)
                    result = False
                End Try
            End If
            Return result
        End Function
    I appreciate your help..... your attitude... not so much...
    Last edited by dontstealmyfish; Sep 22nd, 2011 at 04:09 PM. Reason: typos

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width