목록Categories (1099)
KoreanFoodie's Study
'리버스 엔지니어링 바이블'의 핵심 내용 및 이슈들과 해결책을 다룹니다. Windows programming 맛보기 #include #include #include void RunPorcess() { STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); //start the child process. if (!CreateProcess(NULL, "MyChildProcess", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) ) { printf("CreateProcess failed.\n"); return; } // Wa..
C 언어로 어셈블리 사용해 보기! 어셈블리로 두 변수의 값을 더하는 코드를 짜 보자! #include #include int Plus(int a, int b) { return a +b; } _declspec(naked) PlusAsm(int a, int b) { _asm { mov ebx, dword ptr ss:[esp+8] mov edx, dword ptr ss:[esp+4] add edx, ebx mov eax, edx retn }; } void main(int argc, char *argv[]) { int value = Plus(3, 4); printf("value: %d\n", value); int value2 = PlusAsm(3,4); printf("value2: %d\n", value2);..
스칼라 튜토리얼, scala의 Abstract class에 대해 알아보자 Abstract Class: Specification Abstract Classes can be used to abstract away the implementation details. In short, abstract classes is used for specfication, and concrete sub-classes for implementation. Example: Abstract case for specification abstract class Iter[A] { def getValue: Option[A] def getNext: Iter[A] } def sumElements[A](f: A=>Int)(xs: Iter[A])..
스칼라 튜토리얼, scala의 class에 대해 알아보자 Class: Parameterized Record object gee { val a : Int = 10 def b : Int = a + 20 def f(z: Int) : Int = b + 20 + z } type gee_type = {val a:Int; def b: Int; def f(z:Int): Int} class foo_type(x: Int, y: Int) { val a : Int = x def b : Int = a + y def f(z: Int) : Int = b + y + z } val foo : foo_type = new foo_type(10,20) If you define class, new type is made. The name r..
스칼라 튜토리얼, scala의 sub types에 대해 알아보자 Sub Type Polymorphism (Concept) Let's assume that we want this: object tom { val name = "Tom" val home = "02-880-1234" } object bob { val name = "Bob" val home = "02-123-1234" } def greeting(r: ???) = "Hi " + r.name + ", How are you?" greeting(tom) greeting(bob) // Note that we have tom: {val name: String; val home: String} bob: {val name: String; val mobile: ..
스칼라 튜토리얼, scala의 parametric polymophism에 대해 알아보자 Parametric Polymorphism: Functions Problem def id1(x: Int): Int = x def id2(x: Double): Double = x Can we avoid DRY(Do not Reapeat Yourself)? Parametric Polymorphism(a.k.a. For-all Types) def id[A](x: A): A = x // type for definition val f = (x:Int) => x // type for value The type of id is [A](x: A)A. id is a parametric expression. Only definition..
스칼라 튜토리얼, scala datatypes part2 Pattern Matching A way to use algebraic datatypes Syntax: e match { case C1(...) => e1 ... case Cn(...) => en } Example : sealed abstract class IList case class INil() extends IList case class ICons(hd: Int, tl: IList) extends IList def x: IList = ICons(2, ICons(1, INil())) def length(xs: IList) : Int = xs match { case INil() => 0 case ICons(x, tl) => 1 + length(t..
스칼라 튜토리얼, scala의 datatypes에 대해 알아보자 Types in general Introdection : How to construct elements Elimination : How to use elements of the type Primitive types : Int, Boolean, Double, String... Intro for Int: ...,-2,-1,0,1,2 Elim for Int: +,-,*,/... -Function types : Int => Int, (Int => Int)=>(Int => Int) Intro: (x:T)=>e Elim: f(v) Tuples Intro : (1, 2, 3) : (Int, Int, Int) (1, "a") : (Int, String) ..
스칼라 튜토리얼, scala에서 currying에 대해 알아보자 Currying Why we use currying? Let's look at the code, simplified by currying. def sum(f: Int=>Int, a: Int, b: Int): Int = if (a Int): (Int, Int) => Int = { def sumF(a: Int, b: Int): Int = if (a Int)(a: Int, b: Int): Int = if (a T can be turned into one of type T1 => (T2 => (... Tn =>T) This is called 'currying' named after Haskell Brooks Curry. The opposite di..
스칼라 튜토리얼, scala의 closure에 대해 알아보자 Parameterized expression vs. values Functions defined using “def” are not values but parameterized expressions. • Anonymous functions are values. • But, parameterized expressions are implicitly converted to values. • Explicit conversion: f _ • Anonymous functions can be seen as syntactic sugar: (x:T)=>e is equivalent to { def \_\_noname(x:T) = e; \_\_noname \_ }..