Windows 7 VAN.dll running on Windows 10 21H2
Apr 8, 2024 0:06:50 GMT -8
Post by joleman11 on Apr 8, 2024 0:06:50 GMT -8
Look what I got (kind of) working.
I'll post a write up later.
[EDIT]
Unfortunately, it's still missing some files (probably starting with "wlan"?) as trying to connect to Wi-Fi just closes the window.
How to get it to load:
1. Grab these Windows 7 SP1 files:
-VAN.dll / VAN.dll.mui
-dui70.dll / dui70.dll.mui
-wlanmm.dll / wlanmm.dll.mui
2. Rename dui70 to dui71 and hex edit VAN.dll to reflect this
3. Replace wlanmm.dll and wlanmm.dll.mui in system32 (Might break some stuff in Windows 8+, maybe just extracting resources into this file could work too)
4. Replace VAN.dll and VAN.dll.mui, and copy dui71.dll and dui71.dll.mui to system32
5. (Maybe) regsvr32 VAN.dll
C++ code to create a tray icon to launch the window like in Windows 7 (This should be ported to WindHawk):
Note: Recompile debugMode to false if it launches, it's just to see if it can actually load.
[EDIT 2]
Fixed the formatting of the code.
I'll post a write up later.
[EDIT]
Unfortunately, it's still missing some files (probably starting with "wlan"?) as trying to connect to Wi-Fi just closes the window.
How to get it to load:
1. Grab these Windows 7 SP1 files:
-VAN.dll / VAN.dll.mui
-dui70.dll / dui70.dll.mui
-wlanmm.dll / wlanmm.dll.mui
2. Rename dui70 to dui71 and hex edit VAN.dll to reflect this
3. Replace wlanmm.dll and wlanmm.dll.mui in system32 (Might break some stuff in Windows 8+, maybe just extracting resources into this file could work too)
4. Replace VAN.dll and VAN.dll.mui, and copy dui71.dll and dui71.dll.mui to system32
5. (Maybe) regsvr32 VAN.dll
C++ code to create a tray icon to launch the window like in Windows 7 (This should be ported to WindHawk):
Note: Recompile debugMode to false if it launches, it's just to see if it can actually load.
[EDIT 2]
Fixed the formatting of the code.
#include <Windows.h>
#include <shellapi.h>
#include <stdio.h>
#include <thread>
typedef HRESULT(*DLLFunction)(UINT param_1, int param_2, int param_3, int param_4, HANDLE param_5, int param_6);
HINSTANCE hDLL = LoadLibrary(L"C:/Windows/System32/VAN.dll");
UINT myMessage = RegisterWindowMessageW(L"Microsoft.VAN.Message");
DLLFunction myFunction = (DLLFunction)GetProcAddress(hDLL, "RunVANUI");
HRESULT result = NULL;
bool debugMode = true;
NOTIFYICONDATA notifyIconData;
void PrintErrorMessage(HRESULT hr) {
// Use FormatMessage to get the error message corresponding to HRESULT
LPSTR messageBuffer = nullptr;
DWORD dwSize = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
hr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
reinterpret_cast<LPSTR>(&messageBuffer),
0,
NULL);
if (dwSize == 0) {
printf("Failed to get error message for HRESULT %x\n", hr);
return;
}
// Output the error message
printf("Error: %s %x\n", messageBuffer, hr);
// Free the buffer allocated by FormatMessage
LocalFree(messageBuffer);
}
HRESULT InfiniteTask() {
result = myFunction(myMessage, debugMode ? 5 : 0x8006, 0, 0, (HANDLE)0x0, 1); //5: instant launch // 0x8006: open minimized
if (FAILED(result)) {
PrintErrorMessage(result);
}
return S_OK;
}
LRESULT CALLBACK TrayIconCallback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_USER + 1: // Tray icon callback
switch (LOWORD(lParam)) {
case WM_LBUTTONDOWN: // Right click on tray icon
HWND hwnd = FindWindowExW((HWND)0x0, (HWND)0x0, L"NativeHWNDHost", L"View Available Networks");
if (hwnd) {
if (debugMode)
{
//Keeps window open for easier debugging
ShowWindow(hwnd, 1);
SetForegroundWindow(hwnd);
}
else
{
AllowSetForegroundWindow(0xffffffff);
PostMessageW(hwnd, myMessage, 0, 0);
}
}
break;
}
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
int main() {
// Create a hidden window to handle tray icon messages
WNDCLASS wc = {};
wc.lpfnWndProc = TrayIconCallback;
wc.hInstance = GetModuleHandle(NULL);
wc.lpszClassName = L"TrayIconWindow";
RegisterClass(&wc);
HWND hiddenWindow = CreateWindow(wc.lpszClassName, L"", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
// Add tray icon
memset(¬ifyIconData, 0, sizeof(NOTIFYICONDATA));
notifyIconData.cbSize = sizeof(NOTIFYICONDATA);
notifyIconData.hWnd = hiddenWindow;
notifyIconData.uID = 1;
notifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
notifyIconData.uCallbackMessage = WM_USER + 1;
notifyIconData.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcscpy_s(notifyIconData.szTip, L"Windows 7 VAN.dll TEST");
Shell_NotifyIcon(NIM_ADD, ¬ifyIconData);
std::thread taskThread(InfiniteTask);
// Message loop
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Cleanup
Shell_NotifyIcon(NIM_DELETE, ¬ifyIconData);
DestroyWindow(hiddenWindow);
UnregisterClass(wc.lpszClassName, NULL);
return 0;
}