use the #include <windows.h> make my console crash on windows 10 - c++

I have a program which includes <windows.h> and it works in computers that run windows 7 or 8, but crashes in a computer that runs windows 10. Can you help me?
This is the part of the code that makes my console crash:
#include <cstdlib>
#include <iostream>
#include <conio.h>
#include <ctime>
#include <windows.h>
using namespace std;
void sposta_tu(posizione pos, char cosa){
HANDLE handle = GetStdHandle ( STD_OUTPUT_HANDLE );
COORD coordinate = {pos.y,pos.x};
FillConsoleOutputCharacter ( handle, cosa ,1, coordinate, 0 );
}
void ellimina_tu(posizione pos){
HANDLE handle = GetStdHandle ( STD_OUTPUT_HANDLE );
COORD coordinate = {pos.y,pos.x};
FillConsoleOutputCharacter ( handle,' ',1, coordinate, 0 );
}

BOOL WINAPI FillConsoleOutputCharacter(
_In_ HANDLE hConsoleOutput,
_In_ TCHAR cCharacter,
_In_ DWORD nLength,
_In_ COORD dwWriteCoord,
_Out_ LPDWORD lpNumberOfCharsWritten
);
Last parameter is out parameter, you can't pass 0.
DWORD numberOfCharsWritten;
FillConsoleOutputCharacter(handle, ' ', 1, coordinate, &numberOfCharsWritten);

Related

How to get address of user-defined function?

I am trying to hook a user-defined function. (via DLL injection and inline function hooking)
To do that, I need to get the address of the function to hook in process memory.
I tried various methods to find the address, and finally came up with the equation below.
(offset) = (Address of function in EXE file) - (Image base of EXE file)
(Address of function in process memory) = (GetModuleHandle(NULL)) + (offset)
However, I am not sure if this equation always holds. (For example, when DLL Relocation occurs, I am worried that this equation may be wrong.)
In conclusion, I want to know whether this equation always holds. And if not, I'd like to know how to fix this equation.
(This article has been translated by Google Translate.)
< testwinapi / main.cpp >
#include <stdio.h>
#include <Windows.h>
void capture(HBITMAP* canvas);
int APIENTRY WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) {
while(1) {
HBITMAP canvas;
capture(&canvas);
Sleep(2000);
}
return 0;
}
void capture(HBITMAP* canvas) {
RECT srcRect;
HWND hSrcWnd;
HDC hSrcDC, hDestDC;
hSrcWnd = GetDesktopWindow();
hSrcDC = GetDC(hSrcWnd);
GetWindowRect(hSrcWnd, &srcRect);
int SrceenWidth = srcRect.right - srcRect.left;
int SrceenHeight = srcRect.bottom - srcRect.top;
hDestDC = CreateCompatibleDC(hSrcDC);
*canvas = CreateCompatibleBitmap(hSrcDC, SrceenWidth, SrceenHeight);
SelectObject(hDestDC, *canvas);
for (int y = 0; y < SrceenHeight; y += 50) {
BitBlt(hDestDC, 0, y, SrceenWidth, 50, hSrcDC, 0, y, SRCCOPY);
Sleep(2);
}
ReleaseDC(hSrcWnd, hSrcDC);
DeleteDC(hDestDC);
}
< testdll / dllmain.cpp >
#include "pch.h"
DWORD WriteLog(LPCTSTR format, ...);
void MyCapture(HBITMAP* canvas);
void(*originFunc)(HBITMAP*) = reinterpret_cast<void(*)(HBITMAP*)>(0x941880); //Address of function in process memory
DWORD WriteLog(LPCTSTR lpszFormat, ...) {
TCHAR szLog[512];
DWORD dwCharsWritten;
va_list args;
va_start(args, lpszFormat);
_vstprintf_s(szLog, 512, lpszFormat, args);
va_end(args);
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), szLog, _tcslen(szLog), &dwCharsWritten, NULL);
return dwCharsWritten;
}
void MyCapture(HBITMAP* canvas) {
WriteLog(TEXT("Function called : capture(0x%X)\n"), (DWORD)canvas);
return originFunc(canvas);
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (DetourIsHelperProcess())
return TRUE;
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
AllocConsole();
DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)originFunc, MyCapture);
DetourTransactionCommit();
break;
case DLL_PROCESS_DETACH:
FreeConsole();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)originFunc, MyCapture);
DetourTransactionCommit();
break;
}
return TRUE;
}
< testdll / pch.cpp >
#include "pch.h"
< testdll / pch.h >
#ifndef PCH_H
#define PCH_H
#include "framework.h"
#include <stdio.h>
#include <stdarg.h>
#include <tchar.h>
#include <detours.h>
//MS Detours library
//Can be downloaded from NuGet Package Manager
#endif
< testdll / framework.h >
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
< DLL Injector >
https://github.com/DarthTon/Xenos/releases/latest
After injecting 'testdll.dll' into 'testwinapi.exe', I want to be able to monitor the 'capture' function call. (Because the 'capture' function is reconstructed by reverse engineering, it is assumed that there is no source code for 'testwinapi.exe')
Module relocation occurs as a whole. Individual sections are never moved with respect to the image base. The offsets (RVA) of each section are hardcoded in the module header.
For example:
# Name VirtSize RVA PhysSize Offset
1 .text 000C44C1 00001000 000C4600 00000800
2 .data 00000FEC 000C6000 00000E00 000C4E00
3 .rsrc 00000520 000C7000 00000600 000C5C00
4 .reloc 0000B098 000C8000 0000B200 000C6200
These sections are loaded at specified RVA offsets, regardless of image base address. There's also the implicit "header" section with RVA 0 and size 0x1000, which is why the first section starts at 0x1000. Note that RVA offset != file offset.
So yes, given some known image base and an address inside of it, the offset of that address from the image base will remain constant.
This allows 64-bit code to employ RIP-relative addressing into the .data section, for example, which saves a fixup.

Naivgating to a page using the XAML Hosting API in a Win32 program causes an access violation

I'm using the XAML hosting API to host XAML content in my win32 program. I have successfully initialized the hosting framework and created DesktopWindowXamlSource objects. I have set the Content() of my DesktopWindowXamlSource to a Frame. My problem occurs whenever I try to navigate to a page with that Frame.
To create a Page for my program to use, I followed these steps:
Make IDL definition
namespace Program
{
[default_interface]
runtimeclass SettingsPage: Windows.UI.Xaml.Controls.Page
{
SettingsPage();
}
}
I build the project, copy the generated header and source file from project_root_folder\Debug\Generated Files\sources to the project's root. I then add the files using the Solution Explorer.
I delete the static_assert from each of the files.
I build the project, then I try to navigate to the page by using ContentFrame.Navigate(xaml_typename<winrt::Program::SettingsPage>);
The DesktopWindowXamlSource's content is set to ContentFrame. Every time I try to navigate to the page, I get this error:
Exception thrown at 0x00007FFA08C08106 (Windows.UI.Xaml.dll) in Program.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
My Entrypoint and WindowProc:
#include "pchRT.h"
#include <Windows.h>
#include <windowsx.h>
#include "UIEngine.h"
LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static UI::UIEngine* uiEngine{ nullptr };
switch (msg)
{
case WM_CREATE:
uiEngine = new UI::UIEngine{ reinterpret_cast<HMODULE>(GetWindowLongPtrW(hWnd, GWLP_HINSTANCE)), hWnd };
break;
case WM_GETMINMAXINFO:
{
const auto mmInfo{ reinterpret_cast<LPMINMAXINFO>(lParam) };
mmInfo->ptMinTrackSize.x = 876;
mmInfo->ptMinTrackSize.y = 565;
}
break;
case WM_SIZE:
if (uiEngine)
{
//...
}
break;
case WM_DESTROY:
delete uiEngine;
winrt::uninit_apartment();
PostQuitMessage(0);
break;
default:
return DefWindowProcW(hWnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow)
{
PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY handlePolicy{0};
handlePolicy.HandleExceptionsPermanentlyEnabled = 1;
handlePolicy.RaiseExceptionOnInvalidHandleReference = 1;
SetProcessMitigationPolicy(ProcessStrictHandleCheckPolicy, &handlePolicy, sizeof PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY);
WNDCLASSEXW wc{
sizeof WNDCLASSEXW, CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, WindowProc, 0, 0, hInstance, nullptr,
reinterpret_cast<HCURSOR>(LoadImageW(nullptr, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED)),
reinterpret_cast<HBRUSH>(COLOR_WINDOWTEXT), nullptr, L"Settings Manager", nullptr
};
const auto hWnd{
CreateWindowExW(WS_EX_LAYERED, MAKEINTATOM(RegisterClassExW(&wc)), L"Settings Manager", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, hInstance, nullptr)
};
SetLayeredWindowAttributes(hWnd, 0, 255, LWA_ALPHA);
ShowWindow(hWnd, nCmdShow);
MSG msg;
while (GetMessageW(&msg, nullptr, 0, 0))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
return 0;
}
UIEngine header:
#pragma once
#include "pchRT.h"
#include "resource.h"
#include "MainPage.h"
#include <Windows.h>
#include <dwmapi.h>
#include <string>
#include <fstream>
#include <memory>
#include <vector>
namespace UI
{
class UIEngine
{
HWND XamlIslandsWindow{}, CaptionIslandsWindow{}, Window;
winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource DesktopWindowXamlSource;
winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource CaptionXamlSource;
winrt::Windows::UI::Xaml::Controls::Grid CaptionGrid, PanelGrid{ nullptr };
winrt::Windows::UI::Xaml::Controls::Frame ContentFrame;
bool HandleOverlap;
RECT ClientArea;
HINSTANCE AppInstance;
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Storage::Streams::IRandomAccessStream>
ExtractAndLoadResource(
int resourceId, LPCWSTR resourceType) const;
static winrt::Windows::UI::Xaml::FrameworkElement FindElement(
winrt::Windows::UI::Xaml::FrameworkElement const& startElement, PCWCH name);
public:
explicit UIEngine(HINSTANCE appInstance, HWND hWnd);
};
}
UIEngine implementation:
#include "pchRT.h"
#include "UIEngine.h"
using namespace winrt;
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Xaml::Controls;
using namespace winrt::Windows::UI::Xaml::Media;
using namespace winrt::Windows::UI;
using namespace winrt::Windows::UI::Composition;
using namespace winrt::Windows::UI::Xaml::Input;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Numerics;
using namespace winrt::Windows::Storage::Streams;
using namespace winrt::Windows::UI::Xaml::Media::Imaging;
using namespace winrt::Windows::UI::Xaml::Controls::Primitives;
namespace UI
{
UIEngine::UIEngine(const HINSTANCE appInstance, const HWND hWnd) : Window(hWnd), HandleOverlap(false), AppInstance(appInstance)
{
init_apartment();
auto windowInterop{ DesktopWindowXamlSource.as<IDesktopWindowXamlSourceNative>() }, windowInterop2{
CaptionXamlSource.as<IDesktopWindowXamlSourceNative>()
};
check_hresult(windowInterop->AttachToWindow(hWnd));
check_hresult(windowInterop2->AttachToWindow(hWnd));
windowInterop->get_WindowHandle(&XamlIslandsWindow);
windowInterop2->get_WindowHandle(&CaptionIslandsWindow);
ClientArea.top *= -1;
SetWindowLongPtrW(CaptionIslandsWindow, GWL_EXSTYLE,
GetWindowLongPtrW(CaptionIslandsWindow, GWL_EXSTYLE) | WS_EX_TRANSPARENT);
EnableWindow(CaptionIslandsWindow, FALSE);
SetWindowPos(CaptionIslandsWindow, nullptr, 0, 1, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
SetWindowPos(XamlIslandsWindow, nullptr, 0, ClientArea.top, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
const Border captionBorder;
const AcrylicBrush captionBorderBrush;
captionBorderBrush.TintOpacity(0.65);
captionBorderBrush.TintColor({ 255, 25, 25, 25 });
captionBorderBrush.FallbackColor({ 255, 35, 35, 35 });
captionBorderBrush.BackgroundSource(AcrylicBackgroundSource::HostBackdrop);
captionBorder.Background(captionBorderBrush);
captionBorder.HorizontalAlignment(HorizontalAlignment::Left);
captionBorder.Width(75);
CaptionGrid.Children().Append(captionBorder);
CaptionXamlSource.Content(CaptionGrid);
ContentFrame.Navigate(xaml_typename<winrt::Program::SettingsPage>());
}
}
pchRT.h:
#pragma once
#include <Unknwn.h>
#include <winrt/base.h>
#include <windows.ui.xaml.hosting.desktopwindowxamlsource.h>
#include <winrt/Windows.UI.Xaml.Hosting.h>
#include <winrt/Windows.UI.Xaml.Media.h>
#include <winrt/Windows.UI.Xaml.Controls.h>
#include <winrt/Windows.UI.Xaml.Input.h>
#include <winrt/Windows.UI.h>
#include <winrt/Windows.UI.Input.h>
#include <winrt/Windows.UI.Xaml.h>
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.UI.Xaml.Markup.h>
#include <winrt/Windows.UI.Xaml.Interop.h>
#include <winrt/Windows.Storage.Streams.h>
#include <winrt/Windows.UI.Xaml.Media.Imaging.h>
#include <winrt/Windows.UI.Xaml.Data.h>
My call stack consists of these function calls:
Windows.UI.Xaml.dll!00007ffa08c08106() Unknown
Windows.UI.Xaml.dll!00007ffa08c25edc() Unknown
Windows.UI.Xaml.dll!00007ffa08c27c22() Unknown
Windows.UI.Xaml.dll!00007ffa08c27da7() Unknown
Windows.UI.Xaml.dll!00007ffa08c27ead() Unknown
Windows.UI.Xaml.dll!00007ffa08c28006() Unknown
Windows.UI.Xaml.dll!00007ffa08c280e8() Unknown
Windows.UI.Xaml.dll!00007ffa08c281df() Unknown
Windows.UI.Xaml.dll!00007ffa08b7e225() Unknown
Windows.UI.Xaml.dll!00007ffa08b7e1af() Unknown
> Program.exe!winrt::impl::consume_Windows_UI_Xaml_Controls_INavigate<winrt::Windows::UI::Xaml::Controls::Frame>::Navigate(const winrt::Windows::UI::Xaml::Interop::TypeName & sourcePageType) Line 10998 C++
Program.exe!UI::UIEngine::UIEngine(HINSTANCE__ * appInstance, HWND__ * hWnd, tagRECT clientArea) Line 123 C++
Program.exe!WindowProc(HWND__ * hWnd, unsigned int msg, unsigned __int64 wParam, __int64 lParam) Line 33 C++
[External Code]
Program.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, wchar_t * __formal, int nCmdShow) Line 128 C++
[External Code]
I am compiling my code with the C++/WinRT flag -optimize, and I have included #include "UI.SettingsPage.g.cpp"
So I got this working. You need to follow these steps: Custom Control XAML Hosting API
While following the steps, ignore the directions Add a new UserControl and add a Page instead. Then, in your desktop application, navigate to the page from a Frame created within the UWP app.

GetSystemMetrics return wrong value for my screen

I have a sample code to get the hight and width in pixels.
But it shows the wrong resolution for my screen.
I have 3840 x 2160.
But the application says: 1920 x 1080.
Code:
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
int CDECL MessageBoxPrintf(TCHAR * szCaption, TCHAR * szFormat, int in, int in2)
{
TCHAR szBuffer[1024];
va_list pArgList;
// The va_start macro (defined in STDARG.H) is usually equivalent to
// pArgList = (char *) &szFormat + sizeof (szFormat) ;
va_start(pArgList, szFormat);
// The last argument to wvsprintf points to the arguments
_vsntprintf_s(szBuffer, sizeof (szBuffer) / sizeof (TCHAR),
szFormat, pArgList);
// The va_end macro just zeroes out pArgList for no good reason
va_end(pArgList);
return MessageBox(NULL, szBuffer, szCaption, 0);
}
int WINAPI WinMain(HINSTANCE hTnstance, HINSTANCE hPreVInStane,PSTR szCmdLine, int iCmdShow)
{
int cxScreen=0, cyScreen=0;
cxScreen = GetSystemMetrics(SM_CXSCREEN);
cyScreen = GetSystemMetrics(SM_CYSCREEN);
MessageBoxPrintf(TEXT("ScrnSize"), TEXT("Wide %i High %i"), cxScreen, cyScreen);
return 0;
}
Is this funtion outdated (GetSystemMetrics) or im i doing something wrong?
The issue is due to your display DPI/scailing settings
Please see GetSystemMetrics() returns wrong value for SM_CXSCREEN
And also SetProcessDPIAware and SetProcessDpiAwareness API

Get processID using part of WINDOW heading

i use the following program in c++ ,in Visual C++ 6.0, to inform me with message box when the MS Paint program is opened. It uses the exact name of the WINDOW of MS Paint,which is "Untitled - Paint" . However now i need to make the program inform me with message box when i know only a part of the name of the actual WINDOW , for example , if the window is "Abcdefgh - Paint" and i set the string name in this way - std::wstring windowName(L"Paint"); - the program to work again. Using the following 3 rows of code the program works fine when the actual WINDOW name is the exact name of the MS Paint window:
HWND windowHandle = FindWindowW(NULL, windowName.c_str());
DWORD* processID = new DWORD;
GetWindowThreadProcessId(windowHandle, processID);
But it will not work if the string windowName is just part of the name, i mean if it is "Paint".
Can someone show me how to do this? I thought to take a list of the names of all opened WINDOWS and to compare them with my part of the real name, i mean to search match of the substring "Paint" in their names, but i don't know how to get all opened windows.
Also, this is very important, my computer is old and i am using Visual C++ 6.0, so i can not use all the evolution features of C++ and the program environments nowadays, i mean , i can not use code which is compiled correctly in .NET but does not compiles in Visual C++ 6.0.
Thanks
#include "stdafx.h"
#include < iostream>
#include < string>
#include < windows.h>
#include < sstream>
#include < ctime>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
std::wstring windowName(L"Untitled - Paint");
while(true)
{
Sleep(1000*5);
time_t t = time(0); // get time now
struct tm * now = localtime( & t );
int tday = now->tm_mday;
int tmin = now->tm_min;
int thour = now->tm_hour;
HWND windowHandle = FindWindowW(NULL, windowName.c_str());
DWORD* processID = new DWORD;
GetWindowThreadProcessId(windowHandle, processID);
char probaintstr[20];
sprintf(probaintstr,"%d",*processID);
if(strlen(probaintstr) <=5 )
{
Sleep(1000*10);
MessageBox(NULL,"niama go Notepad ili Wordpad","zaglavie",MB_OK);
}
else {
}
}
return 0;
}
You can use EnumWindows, for example
BOOL CALLBACK enumWindow(HWND hwnd, LPARAM lp)
{
std::string str(512, 0);
int len = GetWindowText(hwnd, &str[0], str.size());
if (str.find("Paint") != std::string::npos)
{
MessageBox(0, str.c_str(), 0, 0);
}
return true;
}
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
EnumWindows(enumWindow, 0);
return 0;
}
Or you can use FindWindowEx and look for classname. The classname for MS Paint is "MSPaintApp". You can find this information from "Spy" utility for windows.
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
for (HWND hwnd = NULL;;)
{
hwnd = FindWindowExA(NULL, hwnd, "MSPaintApp", 0);
if (!hwnd)
break;
std::string str(512, 0);
int len = GetWindowText(hwnd, &str[0], 512);
str.resize(len);
if (str.find("Paint") != std::string::npos)
MessageBox(0, str.c_str(), 0, 0);
}
return 0;
}
For process id you don't need to allocate memory. Just use a reference:
DWORD processID;
GetWindowThreadProcessId(windowHandle, &processID);

mouse hook broke all windows input

I'm new to c++ programming and am trying to make a small reporting tool that will detect when the mouse and keyboard haven't been touched over a period of time.
I have been searching for some example mouse hook code and found this
#define _WIN32_WINNT 0x0400
#pragma comment( lib, "user32.lib" )
#include <windows.h>
#include <stdio.h>
HHOOK hMouseHook;
__declspec(dllexport) LRESULT CALLBACK KeyboardEvent (int nCode, WPARAM wParam, LPARAM lParam)
{
MOUSEHOOKSTRUCT * pMouseStruct = (MOUSEHOOKSTRUCT *)lParam;
if (pMouseStruct != NULL)
printf("Mouse position X = %d Mouse Position Y = %d\n", pMouseStruct->pt.x,pMouseStruct->pt.y);
return CallNextHookEx(hMouseHook,
nCode,wParam,lParam);
}
void MessageLoop()
{
MSG message;
while (GetMessage(&message,NULL,0,0)) {
TranslateMessage( &message );
DispatchMessage( &message );
}
}
DWORD WINAPI MyMouseLogger(LPVOID lpParm)
{
HINSTANCE hInstance = GetModuleHandle(NULL);
if (!hInstance) hInstance = LoadLibrary((LPCSTR) lpParm);
if (!hInstance) return 1;
hMouseHook = SetWindowsHookEx (
WH_MOUSE_LL,
(HOOKPROC) KeyboardEvent,
hInstance,
NULL
);
MessageLoop();
UnhookWindowsHookEx(hMouseHook);
return 0;
}
int main(int argc, char** argv)
{
HANDLE hThread;
DWORD dwThread;
hThread = CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)
MyMouseLogger, (LPVOID) argv[0], NULL, &dwThread);
if (hThread)
return WaitForSingleObject(hThread,INFINITE);
else return 1;
}
I compiled and ran this as a test which seems to do what I wanted. After that I started testing a couple of things. compiled on c++ and g++ for the hell of it. removed the pMouseStruct and tested "if(lParam)" instead. Everything seemed to be behaving and it was getting late so I decided to return to this the next day.
When I booted in to windows today, I was unable to move the mouse or input anything with the keyboard. It seems input inside windows (normal and safe mode) is not working anymore. Any ideas how to fix this?
Using Windows 7 64bit.
So far I have tried the following:
- reversed a recent overclocking tweak.
- returned the code to the way it was before i played with it, recompiled, and ran.
- Googling.
- chkdsk /f on the system drive.
- system restore (doesn't like raid)
- copied user32.dll off a friend.
Plz forgive my ignorance :-)
I ended up reinstalling windows 7 and soon ran into more strange problems. I have since discovered that standby was corrupting various things and have stopped using it. Now I'm running a fresh install of windows 7 that has never been put to sleep. Still don't have any bizarre problems to this day :-)