Ir ao conteúdo
  • Cadastre-se

Mayrinck Bernardo

Membro Pleno
  • Posts

    223
  • Cadastrado em

  • Última visita

  1. clase main package application; import entities.Objeto; public class Program { public static void main(String[] args) { Objeto.name1 = "ola mundo1"; Objeto.setName2() = "ola mundo2"; Objeto.setName3() = "ola mundo3"; System.out.println(Objeto.name1 + Objeto.getName2() + Objeto.getName3() ); } } classe protect package application; public class Protect { protected String name3; } classe objeto package entities; public class Objeto { public static String name1; private String name2; public String getName2() { return this.name2; } public void setName2(String name2) { this.name2 = name2; } } alguem sabe dizer o que tá errado preciso chamar no main pra imprimir só pela variavel nao pode ser to string
  2. obrigado @arfneto sair do 0 #pragma once #include <windows.h> #include <tlhelp32.h> #include <tchar.h> #include <psapi.h> #include "stdio.h" #include "stdlib.h" #include <iostream> using namespace std; int CALLBACK agente(HWND, LPARAM); int main(int argc, char** argv) { DWORD flags = 0; int inherit = 0; ACCESS_MASK access = READ_CONTROL; HDESK desktop = OpenInputDesktop(flags, inherit, access); if (desktop == NULL) return -1; EnumDesktopWindows(desktop, agente, 0); return 0; }; // main() int CALLBACK agente(HWND H, LPARAM P) { char buffer[512]; DWORD pai; LPDWORD pId = &pai; int n = GetWindowTextLengthA(H); char* titulo = (char*)malloc(1 + n); GetWindowTextA(H, titulo, 1 + n); DWORD window_thread = GetWindowThreadProcessId(H, pId); ACCESS_MASK access = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ; HANDLE hProcess = OpenProcess(access, FALSE, pai); if (hProcess == NULL) return -1; n = GetProcessImageFileNameA(hProcess, buffer, 512); if (n <= 0) return -2; char* p = buffer; for (int i = n; i > 1; i -= 1) { if (buffer[i] != '\\') continue; p = buffer + i + 1; break; } // for() if (strlen(titulo) > 0) { printf("Window thread: %8d\ntitulo: '%s'\npai:%8d\nExe: '%s'\n", window_thread, titulo, pai, p); HANDLE hModuleSnap = CreateToolhelp32Snapshot ( TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, pai ); if (hModuleSnap == INVALID_HANDLE_VALUE) { wprintf(L"Format message failed with 0x%x\n", GetLastError()); } MODULEENTRY32 me32; me32.dwSize = sizeof(MODULEENTRY32); if (!Module32First(hModuleSnap, &me32)) { CloseHandle(hModuleSnap); return(FALSE); } _tprintf(TEXT("Mod base address: 0x%08X\n"), (DWORD)me32.modBaseAddr); _tprintf(TEXT("Mod base address: %ld\n"), (DWORD)me32.modBaseAddr); _tprintf(TEXT("\n")); CloseHandle(hModuleSnap); } free(titulo); return 1; }; // agente()
  3. quando testei if (hSnap == INVALID_HANDLE_VALUE)printf("CreateToolhelp32Snapshot error\n\n"); descobrir que todos estão dando erros, mesmo executando como administrador não entendo porque não funciona comigo se fiz tudo certinho mas essa função não ajuda. a saída: o programa: #pragma once #include <windows.h> #include <tlhelp32.h> #include <tchar.h> #include <psapi.h> #include "stdio.h" #include "stdlib.h" int CALLBACK agente(HWND, LPARAM); int main(int argc, char** argv) { DWORD flags = 0; int inherit = 0; ACCESS_MASK access = READ_CONTROL; HDESK desktop = OpenInputDesktop(flags, inherit, access); if (desktop == NULL) return -1; EnumDesktopWindows(desktop, agente, 0); return 0; }; // main() int CALLBACK agente(HWND H, LPARAM P) { char buffer[512]; DWORD pai; LPDWORD pId = &pai; int n = GetWindowTextLengthA(H); char* titulo = (char*)malloc(1 + n); GetWindowTextA(H, titulo, 1 + n); DWORD window_thread = GetWindowThreadProcessId(H, pId); ACCESS_MASK access = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ; HANDLE hProcess = OpenProcess(access, FALSE, pai); if (hProcess == NULL) return -1; n = GetProcessImageFileNameA(hProcess, buffer, 512); if (n <= 0) return -2; char* p = buffer; for (int i = n; i > 1; i -= 1) { if (buffer[i] != '\\') continue; p = buffer + i + 1; break; } // for() if (strlen(titulo) > 0) { printf("Window thread: %8d\ntitulo: '%s'\npai:%8d\nExe: '%s'\n",window_thread, titulo, pai, p); HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, window_thread); if (hSnap == INVALID_HANDLE_VALUE)printf("CreateToolhelp32Snapshot error\n\n"); } free(titulo); return 1; }; // agente()
  4. sim verdade mas seus 2 programas nehum printam na tela o module base adress voce so diz que tem o caminho mas nao mostra e eu estou tentando sair do 0 se é que voce entende.
  5. ok vamos la entao if (strlen(titulo) > 0) { uintptr_t m = GetModuleInformation(hProcess); if (!m)std::cout << "fail "; printf("Window thread: %8d\ntitulo: '%s'\npai:%8d\nExe: '%s'\n' ", window_thread, titulo, pai, p); }
  6. os outros argumentos são como mesmo? #pragma once #include <windows.h> #include <tlhelp32.h> #include <tchar.h> #include <psapi.h> #include "stdio.h" #include "stdlib.h" #include <iostream> using namespace std; int get_process_count() { HANDLE hProcessSnap; PROCESSENTRY32 pe32; pe32.dwSize = sizeof(PROCESSENTRY32); int total_processes = 0; hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hProcessSnap == INVALID_HANDLE_VALUE) { return(-1); } if (!Process32First(hProcessSnap, &pe32)) { CloseHandle(hProcessSnap); return(-2); } do total_processes += 1; while (Process32Next(hProcessSnap, &pe32)) GetModuleInformation(hProcessSnap,); CloseHandle(hProcessSnap); return(total_processes); }; // get_process_count() int main() { int a = get_process_count(); printf("%d",a); return 0; }
  7. então se eu a minha função parar de retornar 0 e retornar algo vai retornar o mesmo numero que está saindo na variavel pai? ahsahsha perguntei isso antes
  8. me ajude aí, tem vários dias tentando... posta uma solução. porque nao usaria?
  9. meu compilador nem reclamou bem lembrado o return te que ser o ultimo argumento eu entendir que precisava ser assim porcausa que o compilador pede com ponteiro eu nunca usei essa função infelizmente ainda não, sinto que estou proximo mas estou aprendendo ainda então como seria o certo? não sou muito acostumado fazer isso
  10. tem um exemplo sobre isso? mas o nome está em char* gostei muito do conversor que postou mas o que fiz errado? #pragma once #include <windows.h> #include <tlhelp32.h> #include <tchar.h> #include <psapi.h> #include "stdio.h" #include "stdlib.h" #include <iostream> using namespace std; int CALLBACK agente(HWND, LPARAM); uintptr_t GetModuleBaseAddress(DWORD procId, const wchar_t* modName); const wchar_t* converte( char* s); int main(int argc, char** argv) { DWORD flags = 0; int inherit = 0; ACCESS_MASK access = READ_CONTROL; HDESK desktop = OpenInputDesktop(flags, inherit, access); if (desktop == NULL) return -1; EnumDesktopWindows(desktop, agente, 0); return 0; }; // main() int CALLBACK agente(HWND H, LPARAM P) { char buffer[512]; DWORD pai; LPDWORD pId = &pai; int n = GetWindowTextLengthA(H); char* titulo = (char*)malloc(1 + n); GetWindowTextA(H, titulo, 1 + n); DWORD window_thread = GetWindowThreadProcessId(H, pId); ACCESS_MASK access = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ; HANDLE hProcess = OpenProcess(access, FALSE, pai); if (hProcess == NULL) return -1; n = GetProcessImageFileNameA(hProcess, buffer, 512); if (n <= 0) return -2; char* p = buffer; for (int i = n; i > 1; i -= 1) { if (buffer[i] != '\\') continue; p = buffer + i + 1; break; } // for() if (strlen(titulo) > 0) { uintptr_t moduleBase = GetModuleBaseAddress(window_thread, converte(titulo)); printf("Window thread: %8d\ntitulo: '%s'\npai:%8d\nExe: '%s'\n' ", window_thread, titulo, pai, p); std::cout << "base adress " << moduleBase << "\n\n" << std::endl; } else { printf("Window thread: %8d\tpai:%8d\tExe: '%s'\n", window_thread, pai, p); } free(titulo); return 1; }; // agente() uintptr_t GetModuleBaseAddress(DWORD procId, const wchar_t* modName) { uintptr_t modBaseAddr = 0; HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId); if (hSnap != INVALID_HANDLE_VALUE) { MODULEENTRY32 modEntry; modEntry.dwSize = sizeof(modEntry); if (Module32First(hSnap, &modEntry)) { do { if (!_wcsicmp(modEntry.szModule, modName)) { modBaseAddr = (uintptr_t)modEntry.modBaseAddr; break; } } while (Module32Next(hSnap, &modEntry)); } } CloseHandle(hSnap); return modBaseAddr; } const wchar_t* converte( char* s) { wchar_t* vetor_wide; vetor_wide = (wchar_t*)malloc(200 * sizeof(char)); int res = MultiByteToWideChar(65001, MB_PRECOMPOSED, s, -1, vetor_wide, sizeof(vetor_wide)); return vetor_wide; free(vetor_wide); }
  11. pode me ajudar a fazer isso então? não to conseguindo #include <stdio.h> #include <iostream> #include <string.h> int main(void) { std::string myString = "Master James"; const char* sz = myString.c_str(); size_t origsizes = strlen(sz) + 1; const size_t newsizes = 500; size_t convertedCharP = 0; wchar_t constTowchar[500]; mbstowcs(&convertedCharP, constTowchar, origsizes, sz, _TRUNCATE); std::wcout << constTowchar << std::endl; }
  12. quero saber se tem como usar o compilador do visualstudio no devc++ ou em outra ide mais leve porque o visual studio é muito pesado a as vezes dá uma travadinha
  13. aqui continua dando 0 adicionado 1 minuto depois #pragma once #include <windows.h> #include <tlhelp32.h> #include <tchar.h> #include <psapi.h> #include "stdio.h" #include "stdlib.h" #include <iostream> using namespace std; int CALLBACK agente(HWND, LPARAM); uintptr_t GetModuleBaseAddress(DWORD procId, const wchar_t* modName); int main(int argc, char** argv) { DWORD flags = 0; int inherit = 0; ACCESS_MASK access = READ_CONTROL; HDESK desktop = OpenInputDesktop(flags, inherit, access); if (desktop == NULL) return -1; EnumDesktopWindows(desktop, agente, 0); return 0; }; // main() int CALLBACK agente(HWND H, LPARAM P) { char buffer[512]; DWORD pai; LPDWORD pId = &pai; int n = GetWindowTextLengthA(H); char* titulo = (char*)malloc(1 + n); GetWindowTextA(H, titulo, 1 + n); DWORD window_thread = GetWindowThreadProcessId(H, pId); ACCESS_MASK access = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ; HANDLE hProcess = OpenProcess(access, FALSE, pai); if (hProcess == NULL) return -1; n = GetProcessImageFileNameA(hProcess, buffer, 512); if (n <= 0) return -2; char* p = buffer; for (int i = n; i > 1; i -= 1) { if (buffer[i] != '\\') continue; p = buffer + i + 1; break; } // for() if (strlen(titulo) > 0) { uintptr_t moduleBase = GetModuleBaseAddress(window_thread, (const wchar_t*)titulo); printf("Window thread: %8d\ntitulo: '%s'\npai:%8d\nExe: '%s'\n' ", window_thread, titulo, pai, p); std::cout << "base adress " << moduleBase << "\n\n" << std:: endl; } else { printf("Window thread: %8d\tpai:%8d\tExe: '%s'\n", window_thread, pai, p); } free(titulo); return 1; }; // agente() uintptr_t GetModuleBaseAddress(DWORD procId, const wchar_t* modName) { uintptr_t modBaseAddr = 0; HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId); if (hSnap != INVALID_HANDLE_VALUE) { MODULEENTRY32 modEntry; modEntry.dwSize = sizeof(modEntry); if (Module32First(hSnap, &modEntry)) { do { if (!_wcsicmp((const wchar_t*)modEntry.szModule, modName)) { modBaseAddr = (uintptr_t)modEntry.modBaseAddr; break; } } while (Module32Next(hSnap, &modEntry)); } } CloseHandle(hSnap); return modBaseAddr; }
  14. eu consegui rodar o programa que voce postou mas nao sei escrever Para uma lista de módulos de um processo eu ainda nao consigo entender bem esses dados typedefs do windows pra mim é complicado saber o caminho e nao conseguir fazer

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!