Home | Info | Community | Development | myReactOS

  1. Home
  2. Info
  3. Community
  4. Development
  5. myReactOS

  1. September 2010
  2. August 2010
  3. July 2010
  4. Recent...
  5. Older...

  1. All
  2. Alex Ionescu
  3. Ged Murphy
  4. janderwald
  5. kjkhyperion
  6. Klemens Friedl
  7. Maarten Bosma
  8. Steven Edwards
  9. Timo Kreuzer

  1. Login
  2. Register

ReactOS Community > ReactOS Blogs

RSS 2.0 News Feed
Atom 1.0 News Feed

Weird gcc stuff.

Posted by Timo Kreuzer on Tuesday, August 19. 2008

Already some time ago I found that amd64-gcc defines X86. So I added an #undef X86 to basetsd.h. So far so good, it seemed to work.

Today I experimented a bit and enabled "-mcmodel=kernel" and suddenly ntoskrnl/ex/init.c didn't compile anymore. The reason was X86 was not defined, so it ran into an #error.
Ooops, that means before this X86 must have been defined. In fact it was although it was effectively #undef'ed in the header (I checked it by adding an #error right after the #undef and then compiling ntoskrnl)
Well it is a precompiled header that somehow doesn't seem to care for that. Well that's when you have "-mcmodel=large" defined (which seems to be the default on mingw64). Any other mcmodel will disable this problem. Nice, but then ntoskrnl won't link anymore.

Let's check that a bit more:


#undef X86
#include "ntoskrnl.h"
#ifdef X86
#error "X86 defined"
#endif


Works without a problem. Now just move that #undef into the first line of ntoskrnl.h or the last line or anywhere else and bang, error!

Now let's do something really funky

#define LONGCAT
#include "ntoskrnl.h"
#ifdef X86
#error "X86 defined"
#endif


together with

#ifdef LONGCAT
#endif


in ntoskrnl.h and... no error! Hmm what has LONGCAT todo with X86 you might ask. Obviously NOTHING.
You can use any define before the precompiled header that is checked or undefined inside the header and suddenly the #undef of gcc-defines like X86 in the pch works.

Anyway, I got rid of it using "-U_X86_" compilerswitch.


Deleted gdi objects in the handle table

Posted by Timo Kreuzer on Friday, September 14. 2007

I am currently working on getting our general gdi object code more windows compatible and more performant. I have been gathering some info on how the stuff works on windows.
These are my findings:

After modifying gdihv (gdi handle viewer, can be found in our rosapps) it showed me all deleted objects. That are objects where bits 16 - 23 of the type field are zero.
Most of the entries in the table are completely empty with all fields zero. But there are several entries, wich are not completely zero.
Example:
Index: 0x1922, ProcessID: 0, KernelData: 0x00001926, Type: 0x00002805 (bitmap)

It looks like the lower 16 bits of the type field are still containing the object type and the reuse counter. Bits 16-23 are 0 and bits 24-31 can still contain some flags.
Now to the KernelData member. It isn't a kernel mode pointer! Most entries have a value of 0x1xxx, so it is also unlikely that it is the lower 16 bits of the former kernel mode pointer. Let's have a look at the example. The KernelData value is 0x1926, wich is pretty near to it's index wich is 0x1922. When we look at index 0x1926, we find this:
Index: 0x1926, ProcessID: 0, KernelData: 0x00001927, Type: 0x00001908 (palette)
And going on with index 0x1927:
Index: 0x1927, ProcessID: 0, KernelData: 0x00001928, Type: 0x00001905 (bitmap)
Index: 0x1928, processID: 0, KernelData: 0x00000000, Type: 0x04001901 (dc)
Looks like KernelData is a link to the next free entry and we have reached the end here.
Every KernelData value of one of these deleted entries points to another deleted entry by index.

Some more interesting facts:
- the first 10 entries in the handle table are completely zero. Probably reserved for something.
- the number of linked, deleted entries is relatively small (was about 100 on my system)
- the free entry with the hightest index has a KernelData of 0 and all following entries are completely zero.

In ReactOS we currently have an additional singly linked list of free entries. But nothing speaks against using the entries themselves as the free list. Disadvantages are that we have no assembly optimized function like InterlockedPopEntrySList, that works with indices into the handle table and there is a small overhead, because both linked deleted entries and complete zero entries must be taken care of.
I already wrote an implemenation for finding a free entry that should be only a little slower. If written in asm it might even be even faster.
But it still bugs me. I need to think a little more about it and I hope I find either a way that would allow a C implemenation that is not slower or I find some other advantage.


fontview and GetFontResourceInfoW

Posted by Timo Kreuzer on Wednesday, June 13. 2007

ThePhysicist wrote:

"And it would be nice to have more dev blogs. Just a few sentences from
time to time apart from the svn commits to see what's going on."


Ok, let's see what I can do about that.

I begin with the stuff I did recently.

Some time ago, when I browsed through bugzilla, I came across a bug, stating that nothing happens, when you doubleclick a font file. Well no surprise, as we didn't have any fontview application. I used google to find out if I could find an open source fontview, maybe from wine, and I found a mailing list entry where a wine dev said that he was going to write such app. That was in 2003, iirc and still no fontview in wine.
So I decided to write a fontview app (can now be found in modules/rosapps).

Most of the stuff was pretty easy, but how to get the face name? You supply fontview.exe with the name of a fontfile on the command line and it needs to figure aout the face name. There's the undocumented gdi32 function GetFontResourceInfoW() and I found enough info on the web to use it for this purpose. But this function was completely unimplemented in ReactOS. So to get the app working on ROS I had to implement this function, both in gdi32 and win32k (NtGdiGetFontResourceInfoInternalW())
So I did some testing, first calling the gdi function, later also calling win32k's NtGdiGetFontResourceInfoInternalW directly using an int 0x2e.


typedef BOOL (WINAPI *PGFRI)(LPCWSTR pwszFiles, DWORD pdwBytes, LPVOID pvBuf,DWORD dwType);
PGFRI GetFontResourceInfoW;

/
Load the GetFontResourceInfo function from gdi32.dll */
HINSTANCE hDLL = LoadLibrary("GDI32.DLL");
GetFontResourceInfoW = (PGFRI)GetProcAddress(hDLL, "GetFontResourceInfoW");



W32KAPI BOOL APIENTRY NtGdiGetFontResourceInfoInternalW(
IN LPWSTR pwszFiles,
IN ULONG cwc,
IN ULONG cFiles,
IN UINT cjIn,
OUT LPDWORD pdwBytes,
OUT LPVOID pvBuf,
IN DWORD dwType
)
{
BOOL ret;

asm volatile ("int $0x2e\n" : "=a"(ret): "a" (0x10b2), "d" (&pwszFiles));

return ret;
}


After some problems in the beginning - I was always getting FALSE returned from win32k (wich means error) because I forgot to translate the filename into Nt format ("??\c:\...") - I was able to gather some additional details about how it works in win32k.

So this is how it basicly works:
- pwszFiles: String containing the filename(s) of the files to get Info from
- pdwBytes: Pointer to a DWORD, IN: Size of the buffer, OUT: Bytes copied
- pvBuf: Pointer to the buffer to recieve the data
- dwType: specifies the Type of info, you want to get

dwType
0 a DWORD, that can be 1 or 2, depending on the font file, don't know excatly
1 long fontname, not suitable for loading the font in some cases
2 a LOGFONTW structure, use lfFaceName member from this one for further use
3 a DWORD, always one if the function succeds(?)
4 returns the full path name, handled by gdi32 only
5 Seems to be a BOOL, wich is TRUE, when the font is not found in the global font table.
return value will be TRUE in this case, even if the font was not found.

returns: TRUE if success, FALSE if no success.

With this info I wrote a basic implementation that allowed to run fontview.exe on ReactOS. It also allows to run ms fontview.exe, but that looks a little ugly. (see pictures at the bottom)

Currently it is only supporting one filename. If someone knows how multiple filenames are handled by the funtion, let me know.

While working on the function in win32k, I came across some issues with our current text rendering code. So I decided to continue the work I had begun some time ago, but quickly abandoned again: Try to get our TextOut and related stuff more compatible with windows.

Hopefully more on that later, so stay tuned...

fontview on ReactOS


MS fontview on ReactOS


News from the Downloader

Posted by Maarten Bosma on Thursday, December 28. 2006

Hurray, the websever is online again and there a news from the downloader.


Continue reading "News from the Downloader"


PackageManager is dead, long live 'Download !'

Posted by Maarten Bosma on Sunday, December 10. 2006

News about the package manager.


Continue reading "PackageManager is dead, long live 'Download !'"


New blog and website.

Posted by Alex Ionescu on Wednesday, November 8. 2006

My new blog and website are available here:
Alex Ionescu


New GUI Boot

Posted by Ged Murphy on Tuesday, October 10. 2006


We have a new GUI boot thanks to a bootvid rewrite by Filip Navara.


Continue reading "New GUI Boot"


Digital Solutions

Posted by Ged Murphy on Thursday, September 28. 2006

The blogging software has been down for me for a while, so I didn't get chance to post this earlier, however on Thursday of last week, I presented 4 seminars on ReactOS at the Digital Solutions day at Bolton University


Continue reading "Digital Solutions"


ReactOS video, printing, hdd died, ...

Posted by Klemens Friedl on Sunday, August 20. 2006

Today, I have done a lot of things and a lot of things have happended.

First, I asked magnus ("greatlord") if he has found the mplayer version he was talking about which should work fine in ReactOS. Although, it turns out later that he don't find a suitable version. The current version of mplayer doesn't allow to output the video via GDI. Older version were able to do this, but we haven't found a suitable one. Just for record, mplayer does work fine in ReactOS 0.3.0, I have outputted a sample video as animated gif and watch the video in Firefox 1.5!


Continue reading "ReactOS video, printing, hdd died, ..."


Wine Test Regression Suite

Posted by janderwald on Wednesday, June 21. 2006


Hi,

this is my first blog on ReactOS. I currently work on improving the shell control panel applets as well as fixing errors detected by the Wine test regression suite. The Wine regression suite tests DLLs API-wise or/and functional-wise. The big advantage of them is that you can compare results with different Microsoft OS and can immediately compare it to ReactOS results. As a result you can see failures very fast and hiden bugs are uncovered. Last but not least its also fun killing bugs :-)


Powered by
Serendipity PHP Weblog




ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.