Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fuck you, win32 API

Name: Anonymous 2009-02-23 20:14

#include <windows.h>
#include <winreg.h>

#define CRYPTLEN    15
#define KEYLEN      29
#define KEYOFFSET   52
#define ALLOCSIZE    256

typedef unsigned char uchar;

char *str = "BCDFGHJKMPQRTVWXY2346789";

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
    HKEY CurrentVersion;
    DWORD type = REG_BINARY;
    uchar *key, *buf;
    int ret = EXIT_FAILURE, size = ALLOCSIZE, i, j, k, l;
   
    if(((NULL == (buf = (uchar*)HeapAlloc(GetProcessHeap(), 0, ALLOCSIZE))) || (NULL == (key = (uchar*)HeapAlloc(GetProcessHeap(), 0, KEYLEN + 1)))) && (buf = "HeapAlloc()"))
        goto _error_malloc;

    if(ERROR_SUCCESS != (i = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\0", 0, KEY_READ, &CurrentVersion)))
        goto _error_RegOpen;

    if((ERROR_SUCCESS != (i = RegQueryValueEx(CurrentVersion, "DigitalProductId\0", NULL, &type, buf, &size))) && RegCloseKey(CurrentVersion))
        goto _error_RegOpen;

    for (i = KEYLEN - 1; i > -1; i--) {
        if((i + 1) % 6 == 0)
            key[i] = '-';
        else {
            k = 0;

            for (j = CRYPTLEN; j > -1; j--) {
                l = (k << 8) | buf[j + KEYOFFSET];
                buf[j + KEYOFFSET] = l / 24;
                k = (l % 24);
            }
           
            key[i] = str[k];
        }
    }
    key[KEYLEN] = '\0';
    MessageBox(NULL, key, "Key:", MB_OKCANCEL);
   
    ret = EXIT_SUCCESS;
    goto _free;
   
    _error_RegOpen:
        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, i, 0, buf, ALLOCSIZE, NULL);
    _error_malloc:
        MessageBox(NULL, buf, "Error", MB_OK);
    _free:
        HeapFree(GetProcessHeap(), 0, buf);
        HeapFree(GetProcessHeap(), 0, key);
        return ret;   
}

Name: Anonymous 2009-02-24 9:15

>>11
I wrote my own compiler which doesn't.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List