• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 23:14
CEST 05:14
KST 12:14
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Serral wins EWC 202543Tournament Spotlight: FEL Cracow 202510Power Rank - Esports World Cup 202580RSL Season 1 - Final Week9[ASL19] Finals Recap: Standing Tall15
Community News
Weekly Cups (Jul 28-Aug 3): herO doubles up6LiuLi Cup - August 2025 Tournaments4[BSL 2025] H2 - Team Wars, Weeklies & SB Ladder10EWC 2025 - Replay Pack4Google Play ASL (Season 20) Announced63
StarCraft 2
General
The GOAT ranking of GOAT rankings RSL Revival patreon money discussion thread Official Ladder Map Pool Update (April 28, 2025) Weekly Cups (Jul 28-Aug 3): herO doubles up Clem Interview: "PvT is a bit insane right now"
Tourneys
LiuLi Cup - August 2025 Tournaments WardiTV Mondays RSL Season 2 Qualifier Links and Dates StarCraft Evolution League (SC Evo Biweekly) Global Tourney for College Students in September
Strategy
Custom Maps
External Content
Mutation # 485 Death from Below Mutation # 484 Magnetic Pull Mutation #239 Bad Weather Mutation # 483 Kill Bot Wars
Brood War
General
ASL Season 20 Ro24 Groups Google Play ASL (Season 20) Announced BW General Discussion StarCraft player reflex TE scores BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues KCM 2025 Season 3 [ASL20] Online Qualifiers Day 2 [CSLPRO] It's CSLAN Season! - Last Chance
Strategy
Fighting Spirit mining rates [G] Mineral Boosting Simple Questions, Simple Answers Muta micro map competition
Other Games
General Games
Stormgate/Frost Giant Megathread Total Annihilation Server - TAForever Nintendo Switch Thread Beyond All Reason [MMORPG] Tree of Savior (Successor of Ragnarok)
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI Russo-Ukrainian War Thread European Politico-economics QA Mega-thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread [\m/] Heavy Metal Thread Korean Music Discussion
Sports
2024 - 2025 Football Thread Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
Gtx660 graphics card replacement Installation of Windows 10 suck at "just a moment" Computer Build, Upgrade & Buying Resource Thread
TL Community
TeamLiquid Team Shirt On Sale The Automated Ban List
Blogs
[Girl blog} My fema…
artosisisthebest
Sharpening the Filtration…
frozenclaw
ASL S20 English Commentary…
namkraft
The Link Between Fitness and…
TrAiDoS
momentary artworks from des…
tankgirl
from making sc maps to makin…
Husyelt
Customize Sidebar...

Website Feedback

Closed Threads



Active: 669 users

W7 CrashFix with WindowMode - Page 2

Forum Index > BW General
Post a Reply
Prev 1 2 All
dosbox
Profile Joined May 2011
27 Posts
July 29 2011 18:54 GMT
#21
On July 30 2011 01:39 WhuazGoodJaggah wrote:
You are right.

When the b.net interface is up, the SWarClass window is not the topmost anymore, this causes the resolution change. I will change the code a little so it wont change the resolution if SDlgDialog is top most, maybe this will help.

The streaming is possible just like when you stream with normal window mode, so you can use procaster or xsplit or whatever.


to spare you some time perhaps,
one major problem is that blizzard wrote all their widgets relative to the screen 0,0 and thats why w-mode or any other alternative "solution" has to be in the lines of 3k lines of code and consider every single widget.
last time i've hooked into bw, there were many instances of "SDlgDialog"...

w-mode grabs all those widgets and renders them relative to the window 0,0 position on move.
so basically you might need to hook w-mode, find its *main* window when in bnet, move it -5, -32, but also trigger correctly that "relocation" of all those child widgets along with it.

some of the above are just speculations...

btw you can use my mod version above - its working ok and compiling without warnings with msvc / gcc...

Azerbaijan
Profile Blog Joined January 2010
United States660 Posts
July 29 2011 22:06 GMT
#22
I have been trying to get my BW to stop crashing in win7 for a few weeks now and I'm getting desperate.

I use the exe that kills explorer and launches the Iccup launcher as well the color fix patch from blizz but my game continues to crash though the colors are fine.

I would like to try the solution in the OP but I kind of clueless about how or why its supposed to work. If I understand correctly it allows me to run BW in windowed mode which will stop the crash but fullscreens it while keeping it at the lowest resolution so that its not too small to play.

If anyone can explain how I can get this working I would appreciate it. I downloaded the exe but when it runs I get a system error, "this program can't start because MSVCR 100.dll is missing from your computer. Try reinstalling the program to fix this problem."

I appreciate any help, I miss and this fix seems very promising.
Count9
Profile Blog Joined May 2009
China10928 Posts
July 30 2011 01:18 GMT
#23
On July 22 2011 19:54 Zyferous wrote:
A while ago, blizzard released a patch fixing the color issue. Personally I've never really suffered from BW crashing very often (maybe once every 100 games), but friends of mine have downloaded that color fix and say that it solved their problem.

But this sounds like a nifty fix for people who rely on WM to not crash. I remember watching my friend change his screen resolution every time he wanted to play BW before we discovered the color fix.

http://us.blizzard.com/support/article.xml?locale=en_US&articleId=36371&pageNumber=1&searchQuery=windows 7

I never knew about this :O I was still using the kill explorer thing.
WhuazGoodJaggah
Profile Blog Joined January 2009
Lesotho777 Posts
Last Edited: 2011-07-30 09:46:28
July 30 2011 09:46 GMT
#24
Allright, I updated the first post with a new version and added a spoilertag for the updated code.
I added all of dosbox' suggestions so you can start the prog now before or after you start bw. The b.net interface shouldn't cause any resolution changes anymore, but since I implemented that a little bit different than dosbox, it might not work for others, please let me know.

@Armathai
I tested streaming with Livestream ProCaster and it worked (my pc is way to slow, but no graphic errors)

@Azerbaijan
I forgot to post a link to the MSVC runtime sutff, I added the link to the first post.
http://www.microsoft.com/download/en/details.aspx?id=5555
download and install this and the error should be gone.

@djcube & peanutter
I conntacted XeNotRoN and told him the issue with the sluggish mouse, we will see whats possible.
small dicks have great firepower
ImbaTosS
Profile Blog Joined January 2009
United Kingdom1689 Posts
July 30 2011 09:52 GMT
#25
On July 22 2011 20:12 MeyerA wrote:
Hm I have a different problem when I'm playing, I get the color bug & the crashes but that's not what is the most annoying. I get small delay/lagg in every game which makes it unplayable, does anyone know a fix for that? (windows 7 x64)


Hi Meyera- I saw you at Dreamhack ^^.

I've noticed that odd problem on my brother's computer, but I've never had it on any of mine. It feels like the game is too fast for the hardware (absurd of course).
EleGant[AoV]
dosbox
Profile Joined May 2011
27 Posts
Last Edited: 2011-07-30 11:11:36
July 30 2011 11:04 GMT
#26
On July 30 2011 18:46 WhuazGoodJaggah wrote:
Allright, I updated the first post with a new version and added a spoilertag for the updated code.
I added all of dosbox' suggestions so you can start the prog now before or after you start bw. The b.net interface shouldn't cause any resolution changes anymore, but since I implemented that a little bit different than dosbox, it might not work for others, please let me know.


there are some major problems still:

1) i get a c0000005 if i try alt+tab-ing multiple times between bw and something else while in the bnet interface. i've noticed this yesterday, so thats why i left full screen bnet out of my attempt. just a guess, but looks to me that w-mode might not be liking that something else is moving the window.
crash-dump:
+ Show Spoiler +

Faulting application starcraft.exe, version 1.16.1.1, faulting module unknown, version 0.0.0.0, fault address 0x00cfa664.

<snip>

eax=6b62c7c7 ebx=00000000 ecx=00000001 edx=00000000 esi=04000d99 edi=0152c000
eip=00cfa664 esp=0012f344 ebp=0012f450 iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00200206

function: <nosymbols>
00cfa5a6 81c704000000 add edi,0x4
00cfa5ac 8b06 mov eax,[esi]
00cfa5ae 81c604000000 add esi,0x4
00cfa5b4 8907 mov [edi],eax
00cfa5b6 81c704000000 add edi,0x4
00cfa5bc 8b06 mov eax,[esi]
00cfa5be 81c604000000 add esi,0x4
00cfa5c4 8907 mov [edi],eax
00cfa5c6 81c704000000 add edi,0x4
00cfa5cc 8b06 mov eax,[esi]
00cfa5ce 81c604000000 add esi,0x4
00cfa5d4 8907 mov [edi],eax
00cfa5d6 81c704000000 add edi,0x4
00cfa5dc 8b06 mov eax,[esi]
00cfa5de 81c604000000 add esi,0x4
00cfa5e4 8907 mov [edi],eax
00cfa5e6 81c704000000 add edi,0x4
00cfa5ec 8b06 mov eax,[esi]
00cfa5ee 81c604000000 add esi,0x4
00cfa5f4 8907 mov [edi],eax
00cfa5f6 81c704000000 add edi,0x4
00cfa5fc 8b06 mov eax,[esi]
00cfa5fe 81c604000000 add esi,0x4
00cfa604 8907 mov [edi],eax
00cfa606 81c704000000 add edi,0x4
00cfa60c 8b06 mov eax,[esi]
00cfa60e 81c604000000 add esi,0x4
00cfa614 8907 mov [edi],eax
00cfa616 81c704000000 add edi,0x4
00cfa61c 8b06 mov eax,[esi]
00cfa61e 81c604000000 add esi,0x4
00cfa624 8907 mov [edi],eax
00cfa626 81c704000000 add edi,0x4
00cfa62c 8b06 mov eax,[esi]
00cfa62e 81c604000000 add esi,0x4
00cfa634 8907 mov [edi],eax
00cfa636 81c704000000 add edi,0x4
00cfa63c 8b06 mov eax,[esi]
00cfa63e 81c604000000 add esi,0x4
00cfa644 8907 mov [edi],eax
00cfa646 81c704000000 add edi,0x4
00cfa64c 8b06 mov eax,[esi]
00cfa64e 81c604000000 add esi,0x4
00cfa654 8907 mov [edi],eax
00cfa656 81c704000000 add edi,0x4
00cfa65c 8b06 mov eax,[esi]
00cfa65e 81c604000000 add esi,0x4
FAULT ->00cfa664 8907 mov [edi],eax ds:0023:0152c000=????????
00cfa666 81c704000000 add edi,0x4
00cfa66c 8b06 mov eax,[esi]
00cfa66e 81c604000000 add esi,0x4
00cfa674 8907 mov [edi],eax
00cfa676 81c704000000 add edi,0x4
00cfa67c 8b06 mov eax,[esi]
00cfa67e 81c604000000 add esi,0x4
00cfa684 8907 mov [edi],eax
00cfa686 81c704000000 add edi,0x4
00cfa68c 8b06 mov eax,[esi]
00cfa68e 81c604000000 add esi,0x4
00cfa694 8907 mov [edi],eax
00cfa696 81c704000000 add edi,0x4
00cfa69c 8b06 mov eax,[esi]
00cfa69e 81c604000000 add esi,0x4
00cfa6a4 8907 mov [edi],eax
00cfa6a6 81c704000000 add edi,0x4
00cfa6ac 8b06 mov eax,[esi]
00cfa6ae 81c604000000 add esi,0x4
00cfa6b4 8907 mov [edi],eax
00cfa6b6 81c704000000 add edi,0x4
00cfa6bc 8b06 mov eax,[esi]
00cfa6be 81c604000000 add esi,0x4
00cfa6c4 8907 mov [edi],eax
00cfa6c6 81c704000000 add edi,0x4
00cfa6cc 8b06 mov eax,[esi]
00cfa6ce 81c604000000 add esi,0x4
00cfa6d4 8907 mov [edi],eax
00cfa6d6 81c704000000 add edi,0x4
00cfa6dc 8b06 mov eax,[esi]
00cfa6de 81c604000000 add esi,0x4
00cfa6e4 8907 mov [edi],eax
00cfa6e6 81c704000000 add edi,0x4
00cfa6ec 8b06 mov eax,[esi]
00cfa6ee 81c604000000 add esi,0x4
00cfa6f4 8907 mov [edi],eax
00cfa6f6 81c704000000 add edi,0x4
00cfa6fc 8b06 mov eax,[esi]
00cfa6fe 81c604000000 add esi,0x4
00cfa704 8907 mov [edi],eax
00cfa706 81c704000000 add edi,0x4
00cfa70c 8b06 mov eax,[esi]
00cfa70e 81c604000000 add esi,0x4
00cfa714 8907 mov [edi],eax

*----> Stack Back Trace <----*
ChildEBP RetAddr Args to Child
0012f450 0000180f 000001e0 0012f4a8 15036589 0xcfa664


2) quiting bw leaves the resolution to 640x480 over here (until you quit "the fix"), also i believe after the first or second start/quit of bw, when you get into the bw window (and the "fix" is running in the bkg), you first need to alt+tab to some other window - then in bw and only then it will enter fullscreen. i think my approach covered all of these issues nicely and you can take another look at it if you want...

some code related remarks:
- the code in the fix is absolutely not requiring the 2010 runtimes at all (until compiled with that newer version compiler). if you build with mingw for example you get pretty much not such dependencies. you could even use msvc 6.0 if it wasn't for EnumDisplayDevices.

- not using CloseHandle(hThread); at the end of main will cause a small memory leak.

- "int main(char argc, char* argv[]) " should be "int main(int argc, char* argv[]) "

- if you change the following to the macro versions the code will become plain c like the base of the api itself:
bool -> BOOL, true -> TRUE, false -> FALSE.

sorry if i'm way to critical or something...
cheers
WhuazGoodJaggah
Profile Blog Joined January 2009
Lesotho777 Posts
July 30 2011 11:46 GMT
#27
Hehe, I like your criticism, don't worry I'm not offended :D

- ofc you are right about the MSVC 2010 runtimes, I just couldn't be fucked to compile it with MinGW.
- forgot about the CloseHandle will fix that thanks.
- fixed the main function
- oh, I didn't know that C doesn't know bool, true and false

I'm currently playing and therefore testing it. I can't reproduce your problem with the resolution begin stuck at 640x480 when quitting bw, allthough I tought my code would do that (I was surprised it worked here, hahaha). I also can't reproduce your crash when I alt+tab in and out of bw in the b.net interface.
I ran into some other problem with bwRepInfo though, and I think my approach is maybe too hacky. I already got a different Idea how to do it, but I have to think it through first.
small dicks have great firepower
dosbox
Profile Joined May 2011
27 Posts
July 30 2011 12:34 GMT
#28
ok cool,
here is a small report from a buddy of mine:
- dual boot vista / win7 on a pc.
- the "not switching from 640x480 until exiting the "fix"" is reproducible on both os he says.
- the crash only occurs on vista on his side (and in my case i have xp), but not on win7.

this is his screen shot (vista):
[image loading]

it slighly hints about the possible bnet ui widget mess-up.
the on-screen copy effect that occurs is because w-mode, after fiddling with all the current widgets present on the ui is combining the ddraw and gdi rendering to one unified surface (i believe). no idea why it does not happen on win7 though.
WhuazGoodJaggah
Profile Blog Joined January 2009
Lesotho777 Posts
Last Edited: 2011-07-30 15:48:47
July 30 2011 15:45 GMT
#29
Ok, the other way works way better. This is the idea:
If broodwar is not minimized it is used, so the resolution is switched to 640x480. As soon as BW is minimized the resolution switches back to the original.

To minimize BW one can not click on the minimize button anymore, and alt+tab wont work either, as its not minimizing bw but switching to another window. To minimize I need an own "command".

So I made a Chaos Launcher plugin now, its subclassing the window and checking for F12, if F12 is pressed BW is minimized and the resolution is restored. If BW gets the focus again, the resolution is changed to 640x480 again. F12 is just a testkey, I couldn't come up with something better, maybe someone has a better idea.

Code:
+ Show Spoiler +
#include <windows.h>
#include <stdio.h>

HANDLE hThread;
BOOL mainThreadRunning = TRUE;
BOOL minimizeBW = FALSE;
LONG prevWindowProc;
DEVMODE lastDevmode;
DEVMODE devmodeBW;


int MainThread();
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
DEVMODE GetCurrentDeviceMode();


BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
DWORD threadId;
hThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)MainThread, 0, 0, &threadId);
break;
case DLL_PROCESS_DETACH:
mainThreadRunning = FALSE;
CloseHandle(hThread);
ChangeDisplaySettings(&lastDevmode, 0);
break;
}

return TRUE;
}

int MainThread() {
Sleep(2000); // wait until BW window is created, 2seconds should be enough

DEVMODE d = GetCurrentDeviceMode();
memcpy(&lastDevmode, &d, sizeof(DEVMODE));
memcpy(&devmodeBW, &d, sizeof(DEVMODE));
devmodeBW.dmPelsWidth = 640;
devmodeBW.dmPelsHeight = 480;

HWND hWndBW = FindWindow("SWarClass", 0);
prevWindowProc = SetWindowLong(hWndBW, GWL_WNDPROC, (LONG)WindowProc);

BOOL wasMinimized = TRUE;

while (mainThreadRunning) {
WINDOWPLACEMENT wndPl;
wndPl.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hWndBW, &wndPl);
if (wndPl.showCmd == SW_SHOWMINIMIZED) {
// set bw resolution
if(!wasMinimized){
ChangeDisplaySettings(&lastDevmode, 0);
wasMinimized = TRUE;
}
} else {
// set normal resolution
if(wasMinimized){
ChangeDisplaySettings(&devmodeBW, 0);
SetWindowPos(hWndBW, 0, -5, -31, 0, 0, SWP_NOSIZE);
wasMinimized = FALSE;
}
}

if (minimizeBW == TRUE) {
ShowWindow(hWndBW, SW_MINIMIZE);
minimizeBW = FALSE;
}
Sleep(250);
}

ChangeDisplaySettings(&lastDevmode, 0);
return 0;
}

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_KEYUP:
if (wParam == VK_F12) {
// minimize bw
minimizeBW = TRUE;
}
break;
}
return CallWindowProc((WNDPROC)prevWindowProc, hwnd, uMsg, wParam, lParam);
}

DEVMODE GetCurrentDeviceMode() {
DISPLAY_DEVICE d;
DEVMODE devMode;
d.cb = sizeof(DISPLAY_DEVICE);
devMode.dmSize = sizeof(DEVMODE);
int devNum = 0;
int result = 0;

do {
result = EnumDisplayDevices(0, devNum, &d, 0);
// check if it's the main device
if (result && ((d.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) != 0)) {
EnumDisplaySettings(d.DeviceName, -1, &devMode);
return devMode;
}
devNum++;
} while (result);

// Current Devicemode not found
devMode.dmSize = 0;
return devMode;
}


Download: http://213.133.99.163/win7bwfix.zip


P.S. really need to get some food now, hahaha
small dicks have great firepower
Armathai
Profile Joined October 2007
1023 Posts
July 30 2011 19:30 GMT
#30
Hey just wanted to report I'm getting mixed results from everything sofar.

I'm using windowed mode + resolution changer as chaoslauncher plugin.

I can use f12 to minimize ingame, but not in chat or lobby.

I'm still getting pretty bad lag with the mouse running in windowed mode(although tried compensating by increasing mousespeed in chaoslauncher, but that makes it jittery), so unless xenotron knows what the issue is, windowed mode kind of doesn't become an option as long as running on laptop rather than desktop(dif refresh rates possible).

Thanks for the work though!
Looking for ArcticCerebrate formerly from @USEast
dosbox
Profile Joined May 2011
27 Posts
Last Edited: 2011-08-01 22:02:18
August 01 2011 20:19 GMT
#31
hi WhuazGoodJaggah,

i like the idea of a shared library for the injector, however it has to be white-listed in *all anti-hack* lauchers and other software or it won't be possible to be used with anti-hack settings enabled to my knowledge.

this is the major reason i sort of branched to the exe path yet again...:
bellow are new modifications (tested on xp, vista, win7):
- i've noticed that you might have found the -32 problematic Y offset on your own - it was causing the glitching of the bnet UI on my end. -31 or higher fixed that, but makes some pixels visible on the top.
- there is an additional thread that updates faster and attempts to grab the alt+tab, winkey and other system keys and minimize before that. this should fix the crash (xp, vista) caused for example by alt+tabbing in and out of the bnet - looks like some sort of a w-mode / win7fixforbw conflict.
- i've copy pasted the earlier IsBroodWarWindow method from your code.

i don't think i will be having much more time to work on this, but hopefully it will be useful to someone...

edit / note:
btw, F12 seems to be taken by Alt+F12 in w-mode, but also it might not always work with a WinProc, since the window loses focus when in the bnet ui.

+ Show Spoiler +


#include <windows.h>
#include <stdio.h>

// structs, vars and flags
DEVMODE lastDevmode;
DEVMODE devmodeBW;
HWND hWndBW = NULL;
BOOL exitThread = FALSE;
BOOL WaitFlag = TRUE;
BOOL isFS = FALSE;
BOOL isMin = TRUE;

// Constant Values
const int BW_FULL_POS_X = -5;
const int BW_FULL_POS_Y = -31; // lower value causes the bnet ui mess-up
const int BW_WIDTH = 650;
const int BW_HEIGHT = 517;

// FUNCTION PROTOTYPES
DEVMODE GetCurrentDeviceMode();
int CheckForegroundWindow();
int KeyHandler();
HWND FindBW();
BOOL IsBroodWarWindow();

#define KEYP(x) (GetKeyState(x) < 0)

// Entry
int main(void) {
// int main(int argc, char* argv[]) {
DWORD threadId, khId;
HANDLE hThread, khThread;
DEVMODE d;

d = GetCurrentDeviceMode();
if (!d.dmSize)
{
printf("Current Devicemode not found, exiting process.\n");
ExitProcess(1);
}

memcpy(&lastDevmode, &d, sizeof(DEVMODE));
memcpy(&devmodeBW, &d, sizeof(DEVMODE));
devmodeBW.dmPelsWidth = 640;
devmodeBW.dmPelsHeight = 480;

printf("\nBroodWar Resolution Changer (by WhuazGoodNjaggah)\n" \
"modified version by Dosbox\n" \
"Press:\n" \
"\t- Alt+F1 if you can't scroll inside BW (See WModeReadme.txt)\n" \
"\t- Alt+Tab, WinKey or Alt+F8 to minimize BW\n" \
"\t- Any key in this window to exit\n\n" \
);

if (FindBW())
printf("BW seems to be active on start.\n");

threadId = khId = 0;
hThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)CheckForegroundWindow, 0, 0, &threadId);
khThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)KeyHandler, 0, 0, &khId);

getchar();

printf("Exiting...\n");
exitThread = TRUE;
CloseHandle(hThread);
CloseHandle(khThread);
ExitProcess(1);
}

// GetCurrentDeviceMode
DEVMODE GetCurrentDeviceMode() {
int devNum = 0;
int result = 0;
DISPLAY_DEVICE d;
DEVMODE devMode;

d.cb = sizeof(DISPLAY_DEVICE);
memset(&devMode, 0, sizeof(DEVMODE));
do {
result = EnumDisplayDevices(0, devNum, &d, 0);
// check if it's the main device
if (result && ((d.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) != 0)) {
EnumDisplaySettings(d.DeviceName, (DWORD)-1, &devMode);
devMode.dmSize = sizeof(DEVMODE);
return devMode;
}
devNum++;
} while (result);

// Current Devicemode not found, exiting process
return devMode;
}

// KeyHandler
int KeyHandler()
{
while(!exitThread) {
if (FindBW()) {
// try minimizing before the actual ALT+TAB or WinKey actions:
// prevent a possible crash on XP / Vista (/ Win7 ?).
if (( KEYP(VK_MENU) && (KEYP(VK_F8) || KEYP(VK_TAB))) ||
KEYP(VK_LWIN) || KEYP(VK_RWIN) )
{
ShowWindow(hWndBW, SW_MINIMIZE);
if (!isMin) {
ChangeDisplaySettings(&lastDevmode, 0);
printf("BW Minimized.\n");
isMin = TRUE;
}
} else {
isMin = FALSE;
}
}
// value should be low
Sleep(1);
}
return 0;
}

// CheckForegroundWindow
int CheckForegroundWindow() {
while(!exitThread) {
if (FindBW()) {
if (!WaitFlag) {
printf("BW Found.\n");
WaitFlag = TRUE;
}
if (IsBroodWarWindow()) {
SetWindowPos(hWndBW, 0, BW_FULL_POS_X, BW_FULL_POS_Y, 0, 0, SWP_NOSIZE);
if (!isFS) {
printf("BW Full Screen.\n");
ChangeDisplaySettings(&devmodeBW, 0);
isFS = TRUE;
}
} else {
SetWindowPos(hWndBW, 0, 0, 0, 0, 0, SWP_NOSIZE);
if (isFS) {
ChangeDisplaySettings(&lastDevmode, 0);
isFS = FALSE;
}
}
} else {
if (WaitFlag) {
printf("Waiting for BW...\n");
ChangeDisplaySettings(&lastDevmode, 0);
WaitFlag = FALSE;
}
}
Sleep(100);
}
return 0;
}

// Find BW
HWND FindBW(void)
{
return hWndBW = FindWindow("SWarClass", 0);
}

// IsBroodWarWindow
BOOL IsBroodWarWindow(void) {
char szWindowClass[255];
int cmpSWC;
int cmpSDD;

RealGetWindowClass(GetForegroundWindow(), szWindowClass, 255);
cmpSWC = strncmp(szWindowClass, "SWarClass", 9);
cmpSDD = strncmp(szWindowClass, "#32770", 6);
return (cmpSWC == 0) || (cmpSDD == 0);
}




(10kb EXE)
http://dl.dropbox.com/u/28720954/bw_fixes/win7fixforbw.exe
-----

Armathai,

i got confirmation that wmode is a bit slow in win7, but this might be DirectDraw or video card / driver related and therefore not easily fixible in w-mode. it seems playable though from the person who explained to me.

----

cheers
WhuazGoodJaggah
Profile Blog Joined January 2009
Lesotho777 Posts
August 02 2011 11:56 GMT
#32
Awesome, I already thought about making a standalone exe again, because I just used the inject way to hook the window proc, but as that was bad in itself the injection isn't really needed.
I didn't have any time until now as I was on the train and bus and such as I'm traveling through Thailand atm.

I really like your changes, altough I think 2 threads are a bit of an overkill but who cares :D
I sure will use it, unfortunately XeNotRoN didn't answer my second email, so still no news on the wmode mouse sluggishness front. It only needs a small fix as the mouse seems not to be sluggish when the cursor is not clipped, but then the scrolling isn't working, I could write a workaround for that but I'd rather have that fix in wmode itself than write yet another ugly workaround.
small dicks have great firepower
MetalSlug
Profile Joined February 2010
Germany443 Posts
August 02 2011 12:45 GMT
#33
You guys know you could just make a XP VM and run BW on that without any crashes or colour issues ?
MKP | Maru | Nada | Boxer | Supernova | Keen
dosbox
Profile Joined May 2011
27 Posts
Last Edited: 2011-08-03 01:33:16
August 02 2011 15:24 GMT
#34
On August 02 2011 20:56 WhuazGoodJaggah wrote:
I sure will use it, unfortunately XeNotRoN didn't answer my second email, so still no news on the wmode mouse sluggishness front. It only needs a small fix as the mouse seems not to be sluggish when the cursor is not clipped, but then the scrolling isn't working, I could write a workaround for that but I'd rather have that fix in wmode itself than write yet another ugly workaround.


i have exchanged some opengl / gfx related emails with him before, but he is usually very busy.
parts of my understanding of the how the bnet interface is made comes from him and the author of dxwnd, who both wrote ~3k lines of code (as i presume and mentioned earlier) to cover the "window mode" issue.

but the thing is that the mouse sluggishness in w-mode is not reproducible on all systems, independent of OS, CPU power, mouse clipping.

i've noticed another problem with moving the window around.
when the user exits the w-mode window title bar is left outside of the screen, so it cannot be moved until the wmode.ini is modifed/reset. instead of hooking the process WH_CALLWNDPROC and listen for close/quit, i've decided to modify wmode.ini directly after the process has terminated (which is probably a worse design decision).

so here is the mod:
// gcc win7fixforbw.c -o win7fixforbw.exe -W -Wall -O3 -lpsapi -s
// cl win7fixforbw.c psapi.lib user32.lib advapi32.lib /W4 /O2 /D_CRT_SECURE_NO_WARNINGS
http://dl.dropbox.com/u/28720954/bw_fixes/win7fixforbw.c
http://dl.dropbox.com/u/28720954/bw_fixes/win7fixforbw.exe

it also locks the console app window (close btn, ctrl+c) until enter is pressed or terminated from taskman.

Prev 1 2 All
Please log in or register to reply.
Live Events Refresh
Next event in 7h 46m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
NeuroSwarm 202
RuFF_SC2 128
StarCraft: Brood War
Backho 182
ggaemo 84
NaDa 51
Bale 32
Noble 20
ajuk12(nOOB) 14
JulyZerg 9
Icarus 5
Stormgate
WinterStarcraft325
Nina198
Dota 2
monkeys_forever851
LuMiX1
League of Legends
JimRising 682
Counter-Strike
PGG 91
Other Games
summit1g23964
shahzam950
C9.Mang0235
Maynarde100
ViBE88
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• Berry_CruncH333
• davetesta49
• practicex 28
• OhrlRock 1
• Kozan
• Migwel
• sooper7s
• AfreecaTV YouTube
• intothetv
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• Doublelift4415
• Rush944
• Stunt253
Other Games
• Scarra1055
Upcoming Events
LiuLi Cup
7h 46m
uThermal 2v2 Circuit
11h 46m
RSL Revival
22h 46m
RSL Revival
1d 6h
SC Evo League
1d 8h
uThermal 2v2 Circuit
1d 11h
CSO Cup
1d 12h
Sparkling Tuna Cup
2 days
uThermal 2v2 Circuit
2 days
Wardi Open
3 days
[ Show More ]
RotterdaM Event
3 days
Replay Cast
3 days
RSL Revival
4 days
The PondCast
6 days
Replay Cast
6 days
Liquipedia Results

Completed

ASL Season 20: Qualifier #2
FEL Cracow 2025
CC Div. A S7

Ongoing

Copa Latinoamericana 4
Jiahua Invitational
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
uThermal 2v2 Main Event
HCC Europe
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025

Upcoming

ASL Season 20
CSLPRO Chat StarLAN 3
BSL Season 21
BSL 21 Team A
RSL Revival: Season 2
Maestros of the Game
SEL Season 2 Championship
WardiTV Summer 2025
Thunderpick World Champ.
MESA Nomadic Masters Fall
CS Asia Championships 2025
Roobet Cup 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.