Why anti virus tool detects my exe as a virus

Tags

Today we had discovered a case where on some windows machines our exe’s started being reported as virus by anti virus tool. While the exact reason is not known, the below stack overflow post gives a very good overview of the problem.

stackoverflow link

In this article there are links to two web pages which are very interesting

  1. https://www.virustotal.com  - you can upload your file here and it will be analyzed by about 50 different antivirus programs (file size < 128MB)
  2. http://www.filedropper.com/ - here you can upload your file and get the link which you can share or embed in your webpage 
Advertisements

Different ways in which functions can be invoked in JavaScript

Tags

There are 4 different ways in which functions can be invoked in JavaScript. The way you invoke determines what the variable “this” evaluates to.

  1. Invoke function without any context i.e. directly calling function as in c programming language (e.g. f();). If function is invoked in this manner then the ‘this’ variable in the function evaluates to global object.
  2. Invoke function in the context of another object, i.e. as a method on an object(e.g. obj.f();). If function is invoked in this manner then the ‘this’ variable evaluates to ‘obj’
  3. Invoke function using new (e.g. var x = new f()). If the function is invoked with new operator then an empty anonymous object is created and ‘this’ variable points to the anonymous object. The anonymous object has a prototype property which points to an object with an constructor property whose value is the function
  4. Invoke function using apply(..) or call(…) method e.g. (f.apply(replacementForthis, argumentsArray) or f.call(replacementForThis, arg1, arg2)). The function f is invoked such that ‘this’ variable is replaced with the value of first parameter and the subsequent arguments are passed as arguments to the function. 

Return value of a function

Function invocation always returns a value, the value returned depends on the type of invocation, for invocations other than new based it returns value of return statement. if there is no return statement or has just empty return statement (like return;) then the returned value is ‘undefined’.

In case the function is invoked with new operator then the return value is ‘this’ object if there is no return statement or return statement returns a non object value. if the return value is an object then that object is returned (e.g  return {a:x}; // returns an object)


function f()
{
return 2;
}
function g()
{
return {a:&amp;quot;x&amp;quot;};
}
var x = new f(); // returns newly created anonymous object
var y = new g(); // returns object {a:&amp;quot;x&amp;quot;}

What is the difference between late binding and early binding

Tags

, ,

early binding is when the compiler knows at compile time what type to bind a variable to, where as late binding is when the binding of the variable is decided at run time.

Example: function overriding is late binding whereas function overloading is early binding. Similarly reflection based method invocation in Java is late binding. In JavaScript functions ‘this’ is late binding.

Class A 
{
 public void f(int x)
 {
 ...
 }
 
 public void g()
 {
 ...
 }
}

Class B extends A 
{
 public void f(int x, int y)
 {
 ...
 }

 public void g()
 {
 ...
 }

}

public static void testBinding(A obj)
{
 obj.f(10); // calls A::f() , early binding
 obj.f(10, 20) // calls B::f(), early binding
 obj.g(); // late binding, cannot determine at compile time whether to call A::g() or B::g()
}

Difference between Framework and Library

Tags

,

The key difference between library and framework is the inversion of control. In case of library the user code calls the library code whereas in case of framework the framework code calls the user code. Frameworks can internally call library code. The pic below explains it (courtesy: http://stackoverflow.com/a/15600924).

Basically framework contains all the wired up skeleton code and user code just need to fill up the skeleton.

Framework vs Library