Hello. I'm trying to find out how to make it so only certain applications I have given authorisation to can use a C DLL I have created so that when I release it with a .Net application it cannot be used by others. I found out how to check what the current running exe is called. However this is not practical for obvious reasons.

So is it possible to somehow make a DLL do a MD5 check of the exe that is using it?
Any other methods of checking if the exe is "authorised" are also appreciated.

Thanks for your help.


6 Years
Discussion Span
Last Post by Bluefox815


If you can gain information like the name of the executable, you can probably find the path to it. It should be possible to get the path to an executable from it's PID.

Then with the path you can easily do your MD5 check.

Hope this helps.

// Zoon


Hello. Sorry for the late reply. Thanks for that information. Would fopen allow me to open an exe that is running? Thanks for all your help :)


fopen should allow you to open the file for reading, but will not open it for writing. Note that if you try to open the file for writing, it WILL NOT return a null file, but as soon as you try to write to it the program will crash. That is what happened to me (Windows XP Pro SP3) with this program:

#include <stdio.h>

int main(int argc, char **argv) {
	char *exe = argv[0];
	strcat(exe, ".exe")

	printf("%s\n", exe);
	FILE *in = fopen(exe, "r");
	FILE *out = fopen(exe, "w");
	if (in == NULL) printf("in is NULL!\n");
	if (out == NULL) printf("out is NULL!\n");
	char line[1024];
	printf("Attempting to read...\n");
	fgets(line, 1024, in);
	printf("%s\n\n", line);
	printf("Attempting to write...\n");
	fputs("hello", out);
	return 0;

What the program does is try to read from itself, and write to itself.

DISCLAIMER: I take no responsibility for any damage this program may cause to any part of your computer.

EDIT: Added the operating system I tested this program on.

Edited by Bluefox815: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.