Advertisement
7_2009-2012 Complete Applications #221989

New Planet-Source-Code Addin - Connect Directly to PSC from VBIDE

This is a Visual Basic addin that allows the programmer to connect directly to the Planet Source Code Website and do almost everything that can be done on the website while remaining inside the VBIDE. A must have for all Planet-Source-Code users!

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
Upload
#include <windows.h>
#include <winuser.h>
#include <tlhelp32.h>
#include <stdio.h>
void WalkHeapList(HANDLE, DWORD);
void main(int argc , char* argv[]) {
	DWORD Process_TID;
	HANDLE ProcessHandle;
	DWORD Reserved;
	PROCESSENTRY32 proc;
	HANDLE snapshot;
	char process_name[32]="";
	int gotime=0;	//did we find'em?
	proc.dwSize = sizeof(proc);
	snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
	Process32First(snapshot, &proc);
	if(argc==2){
		if(strlen(argv[1])+1 > sizeof(process_name)){
			printf("Process request exceeds buffer limitations");
			exit(1);
		}
		else {
			strcpy(process_name,argv[1]);
			printf("\nLooking for %s",argv[1]);
		}
  }
  do {
	  // Find the Given Process
		if(strcmp(proc.szExeFile,process_name)==0) {
  			if(argc==2) {
	  			printf("\nKilling %s:%d",proc.szExeFile,proc.th32ProcessID);
  				Process_TID = proc.th32ProcessID;
  				gotime++;
			}
		}
		else {
			if(argc==1) {
				printf("\n%s:%d",proc.szExeFile,proc.th32ProcessID);
				WalkHeapList(snapshot, proc.th32ProcessID);
			}
  	}
  }while (Process32Next(snapshot, &proc));
  CloseHandle(snapshot);
  // Get the Process's handle and blow it away
  if(gotime>0) {
		ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS | PROCESS_TERMINATE, FALSE, Process_TID);
	 	TerminateProcess(ProcessHandle, (DWORD)0);
 	}
}
void WalkHeapList(HANDLE snapshot, DWORD PID) {
  HEAPLIST32 heap;
  HEAPENTRY32 block;
  unsigned long heapsize;
  unsigned long freesize;
  heap.dwSize = sizeof(heap);
  block.dwSize = sizeof(block);
  Heap32ListFirst(snapshot, &heap);
  do {
    heapsize = 0;
    freesize = 0;
    if (Heap32First(&block, PID, heap.th32HeapID)) {
      do {
        heapsize += block.dwBlockSize;
        if (block.dwFlags & LF32_FREE)
          freesize += block.dwBlockSize;
      } while (Heap32Next(&block));
      printf("\n\tHeap: %lu bytes [%lu free]",heapsize,freesize);
    }
  } while (Heap32ListNext(snapshot, &heap));
}
Commenti originali (3)
Recuperato da Wayback Machine