Skip to content

Instantly share code, notes, and snippets.

View icecoobe's full-sized avatar
🎯
Focusing

Luke icecoobe

🎯
Focusing
View GitHub Profile
@icecoobe
icecoobe / negtest.c
Last active January 2, 2016 16:19
Demo of CPU instruction "neg"
#include <stdio.h>
#include <conio.h>
short negtest(short a);
int main(int argc, char* argv[])
{
short a = 0;
printf("a = %d, result = %d\n", a, negtest(a));
@icecoobe
icecoobe / hBitmap2Ipl.c
Last active May 7, 2016 10:30
Convert "HBITMAP" to "IplImage*"
IplImage* hBitmap2Ipl(HBITMAP hBmp)
{
BITMAP bmp;
::GetObject(hBmp,sizeof(BITMAP),&bmp);
// get channels which equal 1 2 3 or 4
// bmBitsPixel :
// Specifies the number of bits
// required to indicate the color of a pixel.
int nChannels = bmp.bmBitsPixel == 1 ? 1 : bmp.bmBitsPixel/8 ;
@icecoobe
icecoobe / stackoverflow_handler.c
Created January 9, 2014 03:43
Stackoverflow exception handler Once a stackoverflow exception is captured, we should fix the stack and relative mem-page.
/*
* Stackoverflow exception handler
*
* Once a stackoverflow exception is captured, we should fix the stack and relative mem-page.
* Version 0.1
* 2014/01/09
*/
#include <stdio.h>
#include <Windows.h>
@icecoobe
icecoobe / WindowsVersionCode.c
Last active August 29, 2015 13:56
List of Known Versions Of Windows.
struct WindowsNTOSInfo
{
DWORD dwMajorVersion;
DWORD dwMinorVersion;
WORD wServicePackMajor;
//const TCHAR * pcszOSDisplayName;
};
struct WindowsNTOSInfoEx :WindowsNTOSInfo
{
@icecoobe
icecoobe / create_shortcut_for_vm.cpp
Created December 29, 2014 08:10
Create shortcut for virtual machine of virtualbox
#define STRICT // 严格类型检查
#define WIN32_LEAN_AND_MEAN // 剔除不常使用的头文件
#ifdef __cplusplus
# define CINTERFACE // COM头文件有两种定义方式c | c++
#endif // __cplusplus
#ifdef _MSC_VER // Microsoft Visual C++ Compiler
# define _CRT_SECURE_NO_WARNINGS
@icecoobe
icecoobe / elf.h
Created February 20, 2017 16:15 — forked from mlafeldt/elf.h
elf.h for OSX
/* This is the original elf.h file from the GNU C Library; I only removed
the inclusion of feature.h, which is not needed.
On OSX, simply copy the file to /usr/local/include/.
Mathias Lafeldt <mathias.lafeldt@gmail.com> */
/* This file defines standard ELF types, structures, and macros.
Copyright (C) 1995-2003,2004,2005,2006,2007,2008,2009,2010,2011
Free Software Foundation, Inc.
@icecoobe
icecoobe / ExceptionTestForm.cs
Created February 28, 2017 06:18
Exception handling of multiple-threaded model in C#
using System;
using System.Threading;
using System.Windows.Forms;
namespace ET_WinForm
{
public partial class ExceptionTestForm : Form
{
Thread worker = new Thread(Go);
Thread worker2 = new Thread(Back);
@icecoobe
icecoobe / checkCPU.c
Created August 23, 2017 07:12
check whether CPU is little-endian
#include <stdio.h>
#include <stdlib.h>
int is_little_endian(void)
{
union w
{
int a;
char b;
} c;
@icecoobe
icecoobe / class_test.cpp
Created November 20, 2017 09:20
cpp class test
#include <iostream>
using namespace std;
class Base {
// int a;
public:
int a;
Base() { a = 0; }
Base(int x) { a = x; }
@icecoobe
icecoobe / cseh.c
Created November 23, 2017 06:46
SEH in C
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <assert.h>
static void test(void);
static void test2(void);
jmp_buf exception_handled;