Code Monkey home page Code Monkey logo

windowshmodular's Introduction

Modular Windows.h Header File

The Windows.h header file for the Win32 API is a behemoth of include file, adding hundreds of thousands of new macros, structs and functions.

This project aims to modularize the Windows.h file, to only include what you require.

Contribution

All contributions are welcome, if we make this a crowdsourced effort, this can be completed a lot quicker. If any functions are missing, please feel free to add them and submit a pull request. I'll merge them as soon as possible

Usage

The only directory of interest is include, copy the contents of the directory over to your project, set the include path to point to the directory containing the win32 directory.

Due to very generic naming and danger of naming collisions, it's recommended to always keep them in the win32 directory and keep it explicit in the include directives: #include <win32/file.h>.

The win32 directory contains the following:

  • Modular include files:
    • windows_base.h
    • atomic.h
    • dbghelp.h
    • dds.h
    • file.h
    • gdi.h
    • io.h
    • misc.h
    • process.h
    • sysinfo.h
    • threads.h
    • window.h
  • Amalgamated include file (#include'ing the files above):
    • windows_modular.h
  • Full windows include (inlining the files above):
    • windows.h

windows_base.h is included by each of the modular include files, it contains the required types, macros and structures used by multiple modules.

Differences to Microsofts Windows.h

We try to provide a full replacement to Microsofts own headers, while keeping a reasonable amount of compatability and to not break any existing code.

However, there are a few breaking changes you should be aware off:

  1. Functions which exist in two variants, unicode and ascii are missing the generic macro. You have to manually specify if you wish to call the unicode or ascii variant by appending either A or W, for example CreateFileA and CreateFileW.
  2. MIN/MAX macros are not provided, equivalent to #define NOMINMAX.
  3. Many, many functions are still missing. Please provide us with what you need and we try to integrate them as soon as possible.

Testing

The test directory contains a simple test case.

The test case consists of compiling each module file with full warnings turned on, this will make sure all dependencies are met and no warnings are emitted.

It can be executed by calling:

$ nmake

Requires CL.EXE and NMAKE.EXE in your path.

License

This project contains parts of the Microsoft Windows SDK. They're licensed under Microsofts EULA. To use it you must read and agree to it.

The rest is dual-licensed under the "MIT" & "Unlicense" license.

windowshmodular's People

Contributors

afrodave avatar flamaros avatar jlaumon avatar kavika13 avatar leandros avatar lundmark avatar pmttavara avatar samhocevar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windowshmodular's Issues

Concatenated windows.h header has a bunch of extra/trailing whitespace

Easy enough fix to the batch file to solve this. Several fixes like this:

existing code:
echo: >> windows.h

fix:
echo:>> windows.h

When I open files in my editor it highlights trailing whitespace so it's a bit annoying to me personally. I have it solved locally and can submit a PR if interested.

Add items for cute_files library

This is from an older verison, so might not be 100% up to date:

CompareFileTime
WIN32_FILE_ATTRIBUTE_DATA
GET_FILEEX_INFO_LEVELS
GetFileAttributesExA
MAXDWORD

License problems

You're copying directly from the Windows SDK but the license only allows use of those headers and not modification or public distribution. Projects like mingw, Wine, and ReactOS avoid this problem by either doing a clean-room re-implementation or using the MSDN docs.

I was hoping to use this library this in a public-domain project I'm working on, but obviously the copyright violation prevents me. I'm going to continue with my original plan of writing a miniature public domain Windows.h for my own use. If you like, I will send patches that I know are not contaminated by the Microsoft license. With enough incremental changes the entire library would be fixed.

error LNK2019: unresolved external symbol SecureZeroMemory

SecureZeroMemory function is inlined in microsofts headers so WindowsHModular should also embed the implementation.

For details, SecureZeroMemory is a macro defined in WinBase.h (C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\WinBase.h):

#define SecureZeroMemory RtlSecureZeroMemory

and RtlSecureZeroMemory is defined in winnt.h

FORCEINLINE
PVOID
RtlSecureZeroMemory(
    _Out_writes_bytes_all_(cnt) PVOID ptr,
    _In_ SIZE_T cnt
    )
{
    volatile char *vptr = (volatile char *)ptr;

#if defined(_M_AMD64)

    __stosb((PBYTE )((DWORD64)vptr), 0, cnt);

#else

    while (cnt) {

#if !defined(_M_CEE) && (defined(_M_ARM) || defined(_M_ARM64))

        __iso_volatile_store8(vptr, 0);

#else

        *vptr = 0;

#endif

        vptr++;
        cnt--;
    }

#endif // _M_AMD64

    return ptr;
}

Add items for glad/glad_wgl

This was the whole list for me. I generated it a while back, so it's possible there's more now:

HDC
HGLRC
APIENTRY
VOID
DECLARE_HANDLE
FLOAT
INT64
INT32

Copyright header lost

The original copyright header has lost

Copyright (c) Microsoft Corporation. All rights reserved.

The source provenance unclear.

Missing WaitNamedPipeA/WaitNamedPipeW

Also the adjacant error definition, ERROR_PIPE_BUSY is missing.

I think that these are the ones that needs adding:

#define ERROR_PIPE_BUSY 231L
BOOL WINAPI WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut);

Missing SetFileAttributesA/W

I think these are the definitions that should be included:

	BOOL SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes);
	BOOL SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes);

Fail to build on MacOS

I have a M1 machine & it's not possible to build the project ...
I didn't rely on the pre-canned MAKEFILE in test directory (since that simply didn't work at all) & instead, I created a very simple CMakeLists.txt config:

cmake_minimum_required(VERSION 3.10)
project(WindowsHModular)

include_directories(include)

add_library(delta-core STATIC
    # Source files
    test/test.c
    main.c
)

& in the main.c file, I only included the win32/windows.h header.
But the project fails to build running the command cmake --build . with error:

fatal error: too many errors emitted, stopping now [-ferror-limit=]

I'll share a list of the errors. (Most of them, I'm familiar with & know a solution for ... they are simply APIs found only on windows & not on other platforms.)
My entire intention of using WindowsHModular was to build a windows-project which relied on Windows.h header in the code ... So I figured this project would fix the absence of the windows headers ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.