How would I go about writing my own implementation of Win32 functions?

  softwareengineering

So I am currently coding a C program for Windows and come across a little bit of a problem. I’ve been compiling using the mingw-w64 toolchain. In my program, I am attempting to remove as many dependencies as I can. I’ve been using Dependency Walker to see which DLLs my program depends on. My question is how can I implement a function/functions from one of the DLLs my program depends on so that I can remove the dependency? Is there an open-source reference for the implementations (that isn’t Win32 API reference) that shows what’s actually happening in C code? I realize static linking is a thing but that would raise application size a lot for libraries that I only want to use one function from.

Example: I’ve written an example program that uses the GetUserNameW() function from the Windows API to retrieve, store, and eventually print the program runner’s username. This function depends on the Advapi32 lib and Dependency Walker shows this dependency (Advapi32.dll). I want to be able to write my own GetUserNameW() function that behaves in the same way as the Win32 API function but allows me to remove the dependency on Advapi32.dll.

New contributor

baron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT