Reversing OS Loader

Kernel32!LoadLibraryW(LPCWSTR lpFileName)
{
 LoadLibraryExW(lpFileName, 0, 0);
}

Kernel32!LoadLibraryA(LPCSTR lpFileName)
{
 if(lpFileName==NULL)
 {
  LoadLibraryExA(lpFileName, 0, 0);
 }
 else
 {
  int ret1=strcmpi(lpFileName, "twain_32.dll");
  if(ret1!=0)
  {
flag:
   LoadLibraryExA(lpFileName, 0, 0);
   return;
  }

  LPVOID temp=&TEB;
  temp=temp.PEB;
  
  PSTR szDir=(PSTR)RtlAllocateHeap(PEB.ProcessHeap, BaseDllTag, 260);
  if(szDir==NULL)
  {
   jmp flag;
  }
  GetWindowDirectoryA(szDir, 260);
  PSTR pStr=szDir-1;
  do
  {
   char c=*(pStr+1);
   pStr++;
  }while(c!=0);
  PSTR pDll="\twain_32.dll";
  szDir=szDir+pDll;
  HINSTANCE hInst=LoadLibraryA(szDir);
  RtlFreeHeap(PEB.ProcessHeap, 0, szDir);
  if(hInst!=NULL)
  {
   return;
  }
  jmp flag;
 }
}

你可能感兴趣的:(loader)