hyuri: (Thoughtful)
[personal profile] hyuri
a Winamp plugin I’ve been using for a while now decided to randomly break. as in, it started crashing 5 seconds after hitting Play, every time. so, naturally, I decided to poke around in the (happily available) source.

the verdict? how the hell did it work in the first place? O_o I mean, it’s C++—the Microsoft Visual variety—and even I can see serious problems with it. but oddly enough, the part that it’s actually barfing on is a simple call to CHttpFile::SendRequest(). I tried throwing a try block around it to get more info, but the exception type it’s supposed to throw is apparently not present. or at least not completely present. -_-

I suspect it may be related to the almost complete lack of URL encoding involved. (seriously: it replaces spaces with “%20” and that’s it.) was kinda hard to look at with no internet, though.

Date: 2004-09-02 04:57 pm (UTC)
From: [identity profile] soltice.livejournal.com
I thought they recently updated the skinning engine and read something about that breaking a few skins. Of course, I thought that would only apply if you updated.

I've actually had programming problems like that. Not so often now, but certainly when I first started perfectly working code would seem to all of a sudden break. Most of them, I later found out, had to do with the lousy memory scheme of MacOS 7 and that of C++. (Using a reference to an object that was programmically delted elsewhere, but not yet erased out of main memory.)

I mention this because it may be that skin was coded by someone with similar inexperience, and that the error is actually somewhere else and only causing this crash as a side effect.
From: [identity profile] hyuri.livejournal.com
Nah, it’s Winamp 2.92 with a classic style skin—bitmaps only. The plugin in question is actually simple enough that I had a pretty decent start on a C# version of it before I scrapped the whole mess because I could’t figure out the correct way to translate this little snippet:
typedef struct winamp_Plugin_Info {
	int version;
	char *description;
	int (*init)();
	void (*config)();
	void (*quit)();
	HWND hwndParent;
	HINSTANCE hDllInstance;
} winampGeneralPurposePlugin; 
I mean, it’s theoretically written in C++, but it’s just one monster class with some global variables and even functions, C‑style casts only, stupid casts (like casting a private, const variable to a non‑const type to hand it off to an external function (LPSTR, instead of LPCSTR)), important strings scattered all over the place...

Hell, they didn’t even use the STL (char) string‑handling functions: they were manually comparing and constructing strings!

This plugin is my current exercise in masochism. I seriously think I should just rewrite it, using the original as a model, rather than repairing it. Thankfully, it’s small enough that this is actually feasible. ^^;;;
From: [identity profile] soltice.livejournal.com
Actually, that's C. It's an arcaic trick that some programmers used just prior and a little after the acceptance of C++.

This is actually just a straight struct, but it has special variables init, config, and quit that are pointers to C functions.

In this way, the struct becomes a bit like a class. static functions have no need for a reference to the struct, others do. This is usually being taken as the function's first argument.

C++ still offically supports this construct so as to be backwards compatable with C. But, it wouldn't surprise me is MS dropped it in visual C++ do to the problems with being able to treat any pointer as a function.
From: [identity profile] hyuri.livejournal.com
Actually, I meant that the plugin itself is theoretically written in C++. I know what the struct is—hell, I even understand it—but I don't know enough about C# to know what the strict equivalent is—or if there even is one.

Profile

hyuri: (Default)
hyuri

November 2014

S M T W T F S
      1
2345678
9101112131415
161718192021 22
23242526272829
30      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 23rd, 2026 02:17 pm
Powered by Dreamwidth Studios