Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Adding keys to registry via WinAPI and C filter_list
Author
Message
Adding keys to registry via WinAPI and C #1
I really don't know how to write this, but essentially with malware you would want persistency of some sort and the easiest method on Windows I have found thus far is simply adding your program to the registry of HKEY_CURRENT_USER. My setup was simple enough, I just had the program in %APPDATA% and went from there:

Code:
#include <windows.h>

void createRegKey() {

TCHAR szPath[MAX_PATH];
HKEY hkey;

GetModuleFileName( NULL, szPath, sizeof(szPath) );

RegCreateKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL );
RegSetValueEx( hkey, NAME, 0, REG_SZ, ( LPBYTE )szPath, sizeof( szPath ) );
RegCloseKey( hkey );

}

First you get the path of the current running program then you create the key and pass that value to the HKEY datatype. Afterwards you set the value which in my case was just the name of the key itself and also the path of the program. Of course, always close the key after you are done because just like with a file descriptor... it will remain open and possibly cause issues.

Reply





Messages In This Thread
Adding keys to registry via WinAPI and C - by numer_05 - 06-28-2019, 02:19 AM



Users browsing this thread: 3 Guest(s)