Last active
August 29, 2015 14:16
-
-
Save bryc/484341a498858f329c10 to your computer and use it in GitHub Desktop.
g++ 4.8.1 (mingw) - setting registry keys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
windres reg.rc -O coff -o reg.res | |
g++ -c reg.cpp | |
g++ -o reg.exe reg.o reg.res |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <string> | |
#pragma GCC diagnostic ignored "-Wwrite-strings" | |
HKEY OpenKey (HKEY hRootKey, char strKey[]) { | |
HKEY hKey; | |
LONG nError = RegOpenKeyEx (hRootKey, strKey, 0, KEY_ALL_ACCESS, &hKey); | |
if (nError == ERROR_FILE_NOT_FOUND) { | |
RegCreateKeyEx (hRootKey, strKey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); | |
} | |
return hKey; | |
} | |
void SetVal (HKEY hKey, LPCTSTR lpValue, char data[], int lol) { | |
RegSetValueEx (hKey, lpValue, 0, REG_SZ, (LPBYTE)data, lol); | |
} | |
int main() | |
{ | |
HKEY templ = OpenKey(HKEY_CLASSES_ROOT, "."); | |
HKEY handler = OpenKey(HKEY_CLASSES_ROOT, ".0069"); | |
HKEY handler2 = OpenKey(handler, "ShellNew"); | |
HKEY handler3 = OpenKey(handler2, "Config"); | |
SetVal(templ, "", "Empty file", 10); | |
SetVal(handler, "", ".", 1); | |
SetVal(handler2, "NullFile", "", 0); | |
SetVal(handler2, "IconPath", "%SystemRoot%\\System32\\imageres.dll,2", 38); | |
SetVal(handler3, "NoExtension", "", 0); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | |
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | |
<assemblyIdentity | |
version="1.1.1.1" | |
processorArchitecture="X86" | |
name="reg.exe" | |
type="win32" /> | |
<description>what does it matter</description> | |
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | |
<security> | |
<requestedPrivileges> | |
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> | |
</requestedPrivileges> | |
</security> | |
</trustInfo> | |
</assembly> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "winuser.h" | |
1 RT_MANIFEST "reg.exe.manifest" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment