Click here to Skip to main content
15,922,650 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionI want to create an Attendance Register for My Company using VB.net Pin
skullz_softwares5-Oct-07 0:10
skullz_softwares5-Oct-07 0:10 
AnswerRe: I want to create an Attendance Register for My Company using VB.net Pin
Christian Graus5-Oct-07 1:11
protectorChristian Graus5-Oct-07 1:11 
AnswerRe: I want to create an Attendance Register for My Company using VB.net Pin
GuyThiebaut5-Oct-07 4:41
professionalGuyThiebaut5-Oct-07 4:41 
QuestionFilling a typed dataset Pin
steve_rm4-Oct-07 22:16
steve_rm4-Oct-07 22:16 
AnswerRe: Filling a typed dataset Pin
Johan Hakkesteegt5-Oct-07 0:06
Johan Hakkesteegt5-Oct-07 0:06 
QuestionVB DLL Question Pin
yoya03034-Oct-07 22:08
yoya03034-Oct-07 22:08 
AnswerRe: VB DLL Question Pin
Dave Kreskowiak5-Oct-07 1:52
mveDave Kreskowiak5-Oct-07 1:52 
GeneralRe: VB DLL Question Pin
yoya03035-Oct-07 2:15
yoya03035-Oct-07 2:15 
I used VB6 with dll addin plus to compile dll file.
Yes,I called from an outside source.but it dont work.
my dll code:

Public Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Const DLL_PROCESS_DETACH = 0
Public Const DLL_PROCESS_ATTACH = 1
Public Const DLL_THREAD_ATTACH = 2
Public Const DLL_THREAD_DETACH = 3
Public Const MB_OK = &H0&
Public Function DllMain(hInst As Long, fdwReason As Long, lpvReserved As Long) As Boolean
Select Case fdwReason
Case DLL_PROCESS_DETACH
Case DLL_PROCESS_ATTACH
DllMain = True
MessageBox 0, CStr(GetCurrentProcessId()), "aaa", MB_OK
Case DLL_THREAD_ATTACH
MessageBox 0, CStr(GetCurrentProcessId()), "aaa", MB_OK
Case DLL_THREAD_DETACH
End Select
End Function

my ouside code
Public Const PROCESS_VM_READ = &H10
Public Const TH32CS_SNAPPROCESS = &H2
Public Const MEM_COMMIT = 4096
Public Const PAGE_READWRITE = 4
Public Const PROCESS_CREATE_THREAD = (&H2)
Public Const PROCESS_VM_OPERATION = (&H8)
Public Const PROCESS_VM_WRITE = (&H20)
Public Const MB_OK = &H0&
Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByVal lpBuffer As String, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Declare Function GetLastError Lib "kernel32" () As Long
Public Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByVal lpBuffer As String, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Public Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Public Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Public Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Public Declare Function CreateRemoteThread Lib "kernel32" (ByVal hProcess As Long, ByVal lpThreadAttributes As Long, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, ByVal lpParameter As Long, ByVal dwCreationFlags As Long, lpThreadId As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function Process32Next Lib "kernel32" (ByVal hSapshot As Long, lppe As PROCESSENTRY32) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Type PROCESSENTRY32
dwSize As Long
cntUseage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
swFlags As Long
szExeFile As String * 1024
End Type

Public Function EnumAndInject(ByVal ProcessName As String, ByVal DllFileName As String) As Boolean
Dim MySnapHandle As Long
Dim ProcessInfo As PROCESSENTRY32
Dim MyRemoteProcessId As Long
Dim MyDllFileLength As Long
Dim MyDllFileBuffer As Long
Dim MyReturn As Long
Dim MyStartAddr As Long
Dim MyResult As Long
Dim temp As Long

MySnapHandle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
ProcessInfo.dwSize = Len(ProcessInfo)


If Process32First(MySnapHandle, ProcessInfo) <> 0 Then
Do
Debug.Print ProcessInfo.szExeFile
If InStr(LCase(ProcessInfo.szExeFile), ProcessName) > 0 Then

MyRemoteProcessId = OpenProcess(PROCESS_CREATE_THREAD + PROCESS_VM_OPERATION + PROCESS_VM_WRITE + PROCESS_VM_READ, False, ProcessInfo.th32ProcessID)
MyDllFileLength = Len(DllFileName) + 1
MyDllFileBuffer = VirtualAllocEx(MyRemoteProcessId, 0, MyDllFileLength, MEM_COMMIT, PAGE_READWRITE)
MyReturn = WriteProcessMemory(MyRemoteProcessId, MyDllFileBuffer, DllFileName, MyDllFileLength, temp)
MyStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
MyResult = CreateRemoteThread(MyRemoteProcessId, 0, 0, MyStartAddr, MyDllFileBuffer, 0, temp)
End If

Loop While Process32Next(MySnapHandle, ProcessInfo) <> 0
End If


CloseHandle MySnapHandle

End Function
GeneralRe: VB DLL Question Pin
Dave Kreskowiak5-Oct-07 3:50
mveDave Kreskowiak5-Oct-07 3:50 
GeneralRe: VB DLL Question Pin
yoya03035-Oct-07 4:06
yoya03035-Oct-07 4:06 
QuestionData reader (need your help guys) Pin
dienadel4-Oct-07 15:43
dienadel4-Oct-07 15:43 
AnswerRe: Data reader (need your help guys) Pin
Christian Graus4-Oct-07 19:10
protectorChristian Graus4-Oct-07 19:10 
AnswerRe: Data reader (need your help guys) Pin
Dave Kreskowiak5-Oct-07 1:49
mveDave Kreskowiak5-Oct-07 1:49 
GeneralRe: Data reader (need your help guys) Pin
dienadel7-Oct-07 19:51
dienadel7-Oct-07 19:51 
QuestionForms Handling Issue Pin
nlarson114-Oct-07 11:18
nlarson114-Oct-07 11:18 
AnswerRe: Forms Handling Issue Pin
Johan Hakkesteegt5-Oct-07 0:13
Johan Hakkesteegt5-Oct-07 0:13 
GeneralRe: Forms Handling Issue Pin
nlarson115-Oct-07 3:04
nlarson115-Oct-07 3:04 
GeneralRe: Forms Handling Issue Pin
Johan Hakkesteegt5-Oct-07 3:14
Johan Hakkesteegt5-Oct-07 3:14 
QuestionReport from SQL Server with Vb.NET Pin
mhaneefa4-Oct-07 9:41
mhaneefa4-Oct-07 9:41 
AnswerRe: Report from SQL Server with Vb.NET Pin
Johan Hakkesteegt5-Oct-07 0:16
Johan Hakkesteegt5-Oct-07 0:16 
GeneralRe: Report from SQL Server with Vb.NET Pin
mhaneefa5-Oct-07 9:53
mhaneefa5-Oct-07 9:53 
QuestionGet Access() [modified] Pin
zchwllms4-Oct-07 9:28
zchwllms4-Oct-07 9:28 
AnswerRe: Get Access() Pin
balaji baskar4-Oct-07 13:24
balaji baskar4-Oct-07 13:24 
QuestionArray Sort Pin
Scott_Roberts4-Oct-07 8:51
Scott_Roberts4-Oct-07 8:51 
AnswerRe: Array Sort Pin
nlarson114-Oct-07 10:29
nlarson114-Oct-07 10:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.