title: Hooking GetVolumeInformation to return a custom filesystem type
body: <p>I've been attempting (and miserably failing!) at learning how to use Easyhook. I'm trying to hook and return a custom filesystem name for all GetVolumeInformation calls. The following code does hook and I get the filesystem name in debugview, but it crashes the app that loads it.</p>
  
  <p>Any help would be massively appreciated</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;Windows.h&gt;
  #include &lt;easyhook.h&gt;
  
  
  
  
  BOOL WINAPI myhook(LPCTSTR lpRootPathName, LPTSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, LPDWORD lpVolumeSerialNumber, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, LPTSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize);
  
  BOOL WINAPI myhook(LPCTSTR lpRootPathName, LPTSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, LPDWORD lpVolumeSerialNumber, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, LPTSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize)
  {
  
      BOOL retval = GetVolumeInformationW(lpRootPathName, lpVolumeNameBuffer, nVolumeNameSize, lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize);
      if (retval) {
  
        wcscpy_s(lpFileSystemNameBuffer, 8, L"NOTNTFS");
  
        OutputDebugString(lpFileSystemNameBuffer);
  
  
      }
      return retval;
  }
  
  
  BOOL APIENTRY DllMain( HMODULE hModule,
                         DWORD  ul_reason_for_call,
                         LPVOID lpReserved
                       )
  {
  
      HOOK_TRACE_INFO hHook = { NULL }; // keep track of our hook
  
  
  
      switch (ul_reason_for_call)
      {
  
      case DLL_PROCESS_ATTACH:
      {
  
          NTSTATUS result = LhInstallHook(
              GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetVolumeInformationW"),
              myhook,
              NULL,
              &amp;hHook);
          if (FAILED(result))
          {
              OutputDebugStringA("FAILED TO HOOK");
          }
          else {
              OutputDebugStringA("HOOKED");
  
              ULONG ACLEntries[1] = { 0 };
              LhSetInclusiveACL(ACLEntries, 1, &amp;hHook);
  
          }
  
      }
  
  
      case DLL_THREAD_DETACH:
      {
  
  
      }
      case DLL_PROCESS_DETACH:
  
      {
  
      }
          break;
      }
      return TRUE;
  }
  </code></pre>