Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Tuesday, 27 October 2009

EnumPageFiles missing in Windows 2000

Seems like the EnumPageFiles documentation at MSDN is incorrect. EnumPageFiles should be available starting with Windows 2000 Pro, but there's no export with that name in psapi.dll.

This is a dump of the functions available in psapi.dll on my Windows 2000 Pro machine (No service pack installed):

C:\Program Files\Microsoft Visual Studio 8\VC>dumpbin /exports c:\tmp\dump\psapi.dll
Microsoft (R) COFF/PE Dumper Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file c:\tmp\dump\psapi.dll

File Type: DLL

Section contains the following exports for PSAPI.DLL

00000000 characteristics
37EC8753 time date stamp Sat Sep 25 10:26:59 1999
0.00 version
1 ordinal base
19 number of functions
19 number of names

ordinal hint RVA name

1 0 00001CDE EmptyWorkingSet
2 1 00001226 EnumDeviceDrivers
3 2 00001981 EnumProcessModules
4 3 00003106 EnumProcesses
5 4 00001106 GetDeviceDriverBaseNameA
6 5 00001789 GetDeviceDriverBaseNameW
7 6 00001728 GetDeviceDriverFileNameA
8 7 000016D8 GetDeviceDriverFileNameW
9 8 0000185E GetMappedFileNameA
10 9 000017E1 GetMappedFileNameW
11 A 00001BD4 GetModuleBaseNameA
12 B 00001B7E GetModuleBaseNameW
13 C 00001B1D GetModuleFileNameExA
14 D 00001AC7 GetModuleFileNameExW
15 E 00001C35 GetModuleInformation
16 F 00003233 GetProcessMemoryInfo
17 10 00003351 GetWsChanges
18 11 00003317 InitializeProcessForWsWatch
19 12 00001D42 QueryWorkingSet

Summary

4000 .data
1000 .reloc
1000 .rsrc
4000 .text


No EnumPageFiles export. But what if I install service pack 4? Will EnumPageFiles be available there? The answer is no, psapi.dll is not updated while installing the service pack.

When running an application linking to the unavailable EnumPageFiles you will see an error message saying:
The procedure entry point EnumPageFilesA could not be located in the dynamic link library PSAPI.DLL.

The Win2k work-around

You can get the paging files from the registry by reading "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management, PagingFiles".

Do you know of some other method of enumerating the paging files?

Friday, 12 June 2009

NT_ERROR, NT_SUCCESS - identifier not found

After upgrading the Windows SDK I ran into the following compile error, in code which previous to the upgrade compiled without any problems:
error C3861: 'NT_ERROR': identifier not found'
error C3861: 'NT_SUCCESS': identifier not found
'
Turns out that the NT_SUCCESS macro definition has been moved from <stierr.h> to <subauth.h>. NT_ERROR seems to be completely removed from the headers in the new platform SDK.

To solve the problem I created this tiny header file which should work with both the new and old SDK:

#ifndef WINDOWS_NTSTATUS_H
#define WINDOWS_NTSTATUS_H

/**
* @author Roger Karlsson
* @since 2009-03-13
*/

#ifndef NT_SUCCESS
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
#endif

#ifndef NT_ERROR
#define NT_ERROR(Status) ((ULONG)(Status) >> 30 == 3)
#endif

#endif //WINDOWS_NTSTATUS_H

Wednesday, 27 May 2009

Is there any C++ syntax highlighter that outputs data suitable for pasting into a HTML document?

Anyone know of some tool that given a .cpp or .h file outputs data suitable for pasting into a HTML document?

What I want is something like this:

Input:

//My class
class A
{
};


Output:

<span class="cplusplus-comment">//My class</span>
<span class="cplusplus-keyword">class</span> A
{
};

By having spans marking up the keywords, comments and other parts of the code, it's all about adding some CSS code to the stylesheet to have the c++ code highlighted.

Wednesday, 11 March 2009

Windows SDK for Windows Server 2008 and .NET Framework 3.5

Upgrading to the latest Windows platform SDK. Hopefully mscat.h is available in this new SDK and I'll be able to use the catalog functions which are missing in the header files currently installed on my system.

Update: mscat.h is bundled with this version of the Windows SDK. Back to programming..