Skip to content

Instantly share code, notes, and snippets.

View pmachapman's full-sized avatar

Peter Chapman pmachapman

View GitHub Profile
@pmachapman
pmachapman / messagebox_t.c
Created July 9, 2017 22:26
Another example on how to cast a char array to an LPCWSTR
#include <tchar.h>
#include <windows.h>
int main()
{
MessageBox(NULL, _T("Testing, 123!"), _T("Test"), MB_OK);
}
@pmachapman
pmachapman / messagebox.c
Created July 9, 2017 22:25
An example on how to cast a char array to an LPCWSTR
#include <windows.h>
int main()
{
MessageBox(NULL, (LPCWSTR)L"Testing, 123!", (LPCWSTR)L"Test", MB_OK);
}
@pmachapman
pmachapman / guidgenerator.c
Created July 7, 2017 08:13
Generates a GUID
#include <objbase.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
/* Declare variables */
GUID guid;
HRESULT result;
/* Display a help message */
@pmachapman
pmachapman / uuidgenerator.c
Created July 7, 2017 08:08
Generates a UUID
#include <rpc.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
/* Declare variables */
UUID uuid;
RPC_STATUS result;
/* Display a help message */
@pmachapman
pmachapman / ziptogit.sh
Last active May 11, 2017 02:54
Converts a series of zip files into git revisions. Can be used as a one line bash command. Change paths to suit....
#!/bin/bash
for f in `ls -X *.zip | sort --version-sort`;\
do rm -rf ~/source/repos/unrar/* ;\
unzip $f -d ~/source/repos/unrar/ ;\
cd ~/source/repos/unrar/ ;\
git add . ;\
git commit -m "Updated to ${f%.zip}" ;\
cd ~/desktop/unrarsrc/ ;\
done
@pmachapman
pmachapman / targztozip.sh
Last active May 10, 2017 02:52
Converts all tar.gz files in a directory to zip files. Can be used as a one line bash command.
#!/bin/bash
for f in *.tar.gz;\
do rm -rf "${f%.tar.gz}" ;\
mkdir "${f%.tar.gz}" ;\
tar zxvf "$f" -C "${f%.tar.gz}" ;\
zip -r9 "${f%.tar.gz}.zip" "${f%.tar.gz}" ;\
rm -rf "${f%.tar.gz}" ;\
done
@pmachapman
pmachapman / CDKey.c
Last active March 29, 2021 21:20
Microsoft CD Key Validation
/*
This source code contains a authentication routine that will
validate Microsoft CD Keys. It is meant that this source code
is a learning tool and not a PIRACY tool. It is also meant to
show how a large corporation like Microsoft spend MILLIONS of
dollars on development and come up with this protection scheme.
*BorlandC 3.1 was used to compile this successfully.
It is a crime to redistribute these routines in a commercial
@pmachapman
pmachapman / shutdown.asm
Created April 2, 2017 02:29
Simple APM shutdown assembly routine. Compile with: debug < shutdown.asm
N SHUTDOWN.COM
A 100
MOV AX, 1000
MOV SS, AX
MOV SP, F000
MOV AX, 5307
MOV BX, 0001
MOV CX, 0003
INT 15
@pmachapman
pmachapman / reboot.asm
Created April 2, 2017 01:54
Simple "reboot" assembly routine. Compile with: debug < reboot.asm
N REBOOT.COM
A 100
MOV AX, 40
MOV DS, AX
MOV AX, 1234
MOV [72], AX
JMP FFFF:0
R CX
10
@pmachapman
pmachapman / VB6Compatibility.bas
Created December 7, 2016 06:51
Visual Basic 6 Compatibility Routines
Attribute VB_Name = "VB6Compatibility"
Option Explicit
Public Const vbTextCompare = 1
Public Const vbBinaryCompare = 0
Public Function Join(source() As String, Optional sDelim) As String
Dim sOut As String, iC As Integer
If IsMissing(sDelim) Then
sDelim = " "