Jaafar Tribak
Well-known Member
- Joined
- Dec 5, 2002
- Messages
- 9,853
- Office Version
- 2016
- Platform
- Windows
Hi all- This is not really important to most of excel users but it was a good learning exercise and I thought I would post what I did here.
Subclassing office applications via VBA is difficult enough never mind sublcassing a window in a remote process.
In order to achieve this, I wrote a small standard Win32 dll (7,00 ko) in PowerBasic (a close VBA/VB6 dialect) ... This is so that the dll can be injected inside the remote process and then we can call the dll Export function from excel. (VB cannot create Win32 dlls nor Export functions)
The dll doesn't need registration because it is not an ActiveX dll - Also, the dll file doesn't come as a seperate file as I have pre-extratcted the dll bytes and embeeded them inside some VBA arrays so the dll file can be subsequently rebuilt on the fly at runtime.
The Callback function (NewWndProc) is not located inside the dll . It is located in an excel/VBA standard module so that the user/programmer can flexibly control how the window in the remote Process will respond by simply changing/writing the code.
The core of the code relies on the WM_COPYDATA window message which permits Process-Intercommunication
Anyways, here is a Workbook example
Project Code
1- Code in a Standard Module (dllBuilder_bas)
2- Code in a Standard module (dllInjector_bas)
3- Code in a Standard Module (SubClasser_bas)
4- Safety code in the Thisworkbook module
One thing I am still working on is how to delete the dll from disk after closing excel - Any suggestions & observations are welcome.
Subclassing office applications via VBA is difficult enough never mind sublcassing a window in a remote process.
In order to achieve this, I wrote a small standard Win32 dll (7,00 ko) in PowerBasic (a close VBA/VB6 dialect) ... This is so that the dll can be injected inside the remote process and then we can call the dll Export function from excel. (VB cannot create Win32 dlls nor Export functions)
The dll doesn't need registration because it is not an ActiveX dll - Also, the dll file doesn't come as a seperate file as I have pre-extratcted the dll bytes and embeeded them inside some VBA arrays so the dll file can be subsequently rebuilt on the fly at runtime.
The Callback function (NewWndProc) is not located inside the dll . It is located in an excel/VBA standard module so that the user/programmer can flexibly control how the window in the remote Process will respond by simply changing/writing the code.
The core of the code relies on the WM_COPYDATA window message which permits Process-Intercommunication
Anyways, here is a Workbook example
Project Code
1- Code in a Standard Module (dllBuilder_bas)
Code:
Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias _
"RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private ar1() As Variant, ar2() As Variant, ar3() As Variant, ar4() As Variant, ar5() As Variant, ar6() As Variant
Private ar7() As Variant, ar8() As Variant, ar9() As Variant, ar10() As Variant, ar11() As Variant, ar12() As Variant
Private Sub GetDllBytes1()
ar1 = Array(77, 90, 10, 0, 2, 0, 0, 0, 4, 0, 15, 0, 255, 255, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 180, 9, 102, 186, 16, 0, 14, 31, 205, 33, 102, 184, 1, 76, 205, 33, 84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 87, 105, 110, 51, 50, 32, 112, 114, 111, 103, _
114, 97, 109, 46, 13, 10, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 69, 0, 0, 76, 1, 4, 0, 57, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 14, 35, 11, 1, 2, 52, 104, 14, 0, 0, 0, 8, 0, 0, 164, 8, 0, 0, 40, 22, 0, 0, 0, 16, 0, 0, 0, 32, 0, 0, 0, 0, 32, 0, 0, 16, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, _
4, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 16, 0, 0, 64, 0, 0, 0, 0, 1, 0, 0, 16, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 16, 51, 0, 0, 77, 0, 0, 0, 0, 48, 0, 0, 12, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 15, 7, 0, 0, 199, 5, 48, 38, 32, 0, 240, 19, 32, 0, 199, 5, 52, 38, 32, 0, 116, 20, 32, 0, 199, 5, 56, 38, 32, 0, 104, 21, 32, 0, 199, 5, 60, 38, 32, 0, 108, 21, 32, 0, 199, 5, 64, 38, 32, 0, 112, 21, 32, 0, 199, 5, 68, 38, 32, 0, 113, 21, 32, 0, 199, 5, 72, 38, 32, 0, 117, 21, 32, 0, 199, _
5, 76, 38, 32, 0, 121, 21, 32, 0, 139, 229, 93, 195, 0, 0, 0, 0, 0, 0, 0, 155, 16, 32, 0, 0, 0, 0, 0, 112, 98, 85, 139, 236, 83, 86, 87, 104, 63, 19, 0, 0, 131, 236, 112, 104, 106, 16, 32, 0, 49, 246, 86, 86, 86, 86, 86, 255, 117, 12, 106, 252, 255, 117, 8, 255, 21, 88, 49, 32, 0, 217, 109, 240, 137, 133, 104, 255, 255, 255, 139, 133, 104, 255, 255, 255, 141, 101, 244, 95, 94, 91, 93, 194, 8, 0, 0, 0, 0, 0, 0)
ar3 = Array(0, 0, 68, 17, 32, 0, 0, 0, 0, 0, 112, 98, 85, 139, 236, 83, 86, 87, 104, 63, 19, 0, 0, 131, 236, 112, 104, 188, 16, 32, 0, 49, 246, 86, 86, 86, 86, 186, 100, 42, 32, 0, 232, 113, 13, 0, 0, 106, 0, 139, 220, 232, 235, 12, 0, 0, 255, 21, 68, 49, 32, 0, 217, 109, 240, 80, 255, 21, 92, 49, 32, 0, 217, 109, 240, 137, 5, 84, 42, 32, 0, 186, 116, 42, 32, 0, 232, 69, 13, 0, 0, 106, 0, 139, 220, 232, 191, 12, 0, 0, _
255, 21, 68, 49, 32, 0, 217, 109, 240, 80, 255, 21, 92, 49, 32, 0, 217, 109, 240, 137, 5, 88, 42, 32, 0, 184, 93, 17, 32, 0, 80, 255, 53, 88, 42, 32, 0, 232, 44, 255, 255, 255, 137, 5, 80, 42, 32, 0, 141, 101, 244, 95, 94, 91, 93, 195, 0, 0, 0, 0, 0, 0, 0, 220, 19, 32, 0, 0, 0, 0, 0, 112, 98, 85, 139, 236, 83, 86, 87, 104, 63, 19, 0, 0, 131, 236, 112, 104, 93, 17, 32, 0, 49, 246, 49, 255, 185, 15, 0, 0, _
0, 86, 73, 117, 252, 106, 0, 255, 53, 84, 42, 32, 0, 255, 21, 80, 49, 32, 0, 217, 109, 240, 143, 69, 208, 59, 69, 208, 15, 133, 25, 0, 0, 0, 255, 53, 80, 42, 32, 0, 106, 252, 255, 117, 8, 255, 21, 88, 49, 32, 0, 217, 109, 240, 233, 41, 2, 0, 0, 139, 69, 12, 137, 133, 76, 255, 255, 255, 139, 69, 16, 137, 133, 80, 255, 255, 255, 139, 69, 20, 137, 133, 84, 255, 255, 255, 199, 133, 96, 255, 255, 255, 16, 0, 0, 0, 199, 133, 92, 255, _
255, 255, 3, 0, 0, 0, 141, 157, 76, 255, 255, 255, 139, 195, 137, 133, 100, 255, 255, 255, 141, 157, 92, 255, 255, 255, 83, 255, 117, 8, 106, 74, 255, 53, 84, 42, 32, 0, 255, 21, 84, 49, 32, 0, 217, 109, 240, 219, 69, 12, 219, 125, 176, 219, 5, 136, 42, 32, 0, 219, 109, 176, 222, 217, 223, 224, 158, 15, 133, 57, 1, 0, 0, 199, 133, 96, 255, 255, 255, 16, 0, 0, 0, 199, 133, 92, 255, 255, 255, 3, 0, 0, 0, 141, 157, 76, 255, 255, 255, 139, _
195, 137, 133, 100, 255, 255, 255, 106, 4, 255, 117, 20, 141, 157, 68, 255, 255, 255, 137, 59, 83, 255, 21, 100, 49, 32, 0, 139, 189, 68, 255, 255, 255, 217, 109, 240, 106, 4, 184, 4, 0, 0, 0, 139, 77, 20, 3, 193, 80, 141, 157, 72, 255, 255, 255, 137, 51, 83, 255, 21, 100, 49, 32, 0, 139, 181, 72, 255, 255, 255, 217, 109, 240, 106, 4, 184, 8, 0, 0, 0, 139, 77, 20, 3, 193, 80, 141, 157, 64, 255, 255, 255, 83, 255, 21, 100, 49, 32, 0, 217, _
109, 240, 106, 16, 255, 181, 64, 255, 255, 255, 141, 157, 76, 255, 255, 255, 83, 255, 21, 100, 49, 32, 0, 217, 109, 240, 131, 189, 88, 255, 255, 255, 1, 117, 17, 139, 133, 76, 255, 255, 255, 137, 5, 92, 42, 32, 0, 233, 4, 1, 0, 0, 139, 133, 76, 255, 255, 255, 137, 5, 92, 42, 32, 0, 139, 133, 76, 255, 255, 255, 137, 69, 12, 139, 133, 80, 255, 255, 255, 137, 69, 16, 139, 133, 84, 255, 255, 255, 137, 69, 20, 255, 53, 80, 42, 32, 0, 106, 252, 255)
ar4 = Array(117, 8, 255, 21, 88, 49, 32, 0, 217, 109, 240, 255, 181, 84, 255, 255, 255, 255, 181, 80, 255, 255, 255, 255, 181, 76, 255, 255, 255, 255, 117, 8, 255, 21, 84, 49, 32, 0, 217, 109, 240, 184, 93, 17, 32, 0, 80, 255, 53, 88, 42, 32, 0, 232, 40, 253, 255, 255, 137, 5, 80, 42, 32, 0, 139, 133, 76, 255, 255, 255, 137, 5, 92, 42, 32, 0, 233, 131, 0, 0, 0, 233, 77, 0, 0, 0, 219, 5, 132, 42, 32, 0, 219, 109, 176, 222, 217, 223, 224, 158, _
116, 20, 219, 5, 128, 42, 32, 0, 219, 109, 176, 222, 217, 223, 224, 158, 15, 133, 41, 0, 0, 0, 255, 53, 80, 42, 32, 0, 106, 252, 255, 117, 8, 255, 21, 88, 49, 32, 0, 217, 109, 240, 106, 0, 106, 0, 106, 2, 255, 53, 84, 42, 32, 0, 255, 21, 84, 49, 32, 0, 217, 109, 240, 139, 69, 12, 59, 5, 92, 42, 32, 0, 117, 5, 233, 33, 0, 0, 0, 255, 117, 20, 255, 117, 16, 255, 117, 12, 255, 117, 8, 255, 53, 80, 42, 32, 0, 255, 21, 76, _
49, 32, 0, 217, 109, 240, 137, 133, 104, 255, 255, 255, 139, 133, 104, 255, 255, 255, 141, 101, 244, 95, 94, 91, 93, 194, 16, 0, 0, 0, 0, 0, 8, 0, 0, 0, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 129, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 130, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 131, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 132, _
35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 133, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 134, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 135, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 136, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70, 1, 0, 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70, _
132, 178, 150, 177, 180, 186, 26, 16, 182, 156, 0, 170, 0, 52, 29, 7, 134, 178, 150, 177, 180, 186, 26, 16, 182, 156, 0, 170, 0, 52, 29, 7, 0, 4, 2, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 17, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 18, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 19, 35, 0, 0, 112, _
35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 20, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 21, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 22, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 23, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 24, 35, 0, 0, 112, 35, 0, 35, 0, 0, 35, 112, 0, 0, 0, 0, 25, 0, 0, 35, 112, 0, 0, 0, 0)
ar5 = Array(129, 92, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 14, 0, 100, 0, 225, 255, 66, 98, 72, 104, 79, 111, 81, 113, 8, 8, 8, 8, 16, 16, 2, 2, 63, 19, 50, 19, 63, 27, 63, 31, 63, 23, 5, 132, 0, 64, 28, 70, 0, 0, 200, 66, 0, 0, 0, 127, 0, 0, 0, 63, 0, 0, 192, 255, 0, 0, 128, 127, 53, 194, 104, 33, 162, 218, 15, 201, _
255, 63, 53, 194, 104, 33, 162, 218, 15, 201, 254, 63, 133, 100, 222, 249, 51, 243, 4, 181, 255, 63, 0, 66, 192, 255, 0, 72, 192, 255, 0, 74, 192, 255, 80, 0, 111, 0, 119, 0, 101, 0, 114, 0, 66, 0, 65, 0, 83, 0, 73, 0, 67, 0, 0, 0, 67, 79, 78, 73, 78, 36, 0, 116, 99, 112, 0, 144, 0, 0, 0, 1, 128, 0, 0, 0, 44, 34, 97, 24, 32, 0, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, _
85, 139, 236, 83, 86, 87, 187, 0, 32, 32, 0, 102, 247, 5, 10, 22, 32, 0, 0, 1, 117, 5, 233, 30, 2, 0, 0, 233, 44, 4, 0, 0, 255, 21, 32, 49, 32, 0, 131, 248, 255, 249, 116, 64, 137, 131, 224, 5, 0, 0, 199, 131, 232, 5, 0, 0, 0, 0, 0, 0, 232, 235, 2, 0, 0, 114, 41, 137, 131, 228, 5, 0, 0, 199, 64, 104, 1, 0, 0, 0, 199, 64, 108, 1, 0, 0, 0, 199, 64, 112, 2, 0, 0, 0, 199, 64, 116, 3, 0, 0, _
0, 199, 64, 120, 0, 0, 0, 0, 195, 232, 243, 2, 0, 0, 114, 12, 255, 179, 224, 5, 0, 0, 255, 21, 36, 49, 32, 0, 195, 233, 82, 249, 255, 255, 139, 55, 131, 199, 4, 209, 238, 114, 20, 116, 17, 209, 238, 115, 37, 193, 230, 2, 139, 52, 51, 232, 84, 6, 0, 0, 235, 228, 195, 209, 238, 114, 35, 193, 230, 2, 184, 1, 0, 0, 0, 83, 3, 222, 232, 130, 1, 0, 0, 91, 235, 204, 193, 230, 2, 139, 12, 51, 227, 196, 81, 139, 9, 255, 81, 8, _
235, 188, 193, 230, 2, 141, 12, 51, 81, 255, 21, 60, 49, 32, 0, 235, 173, 131, 248, 1, 124, 7, 61, 255, 0, 0, 0, 126, 2, 176, 5, 233, 100, 1, 0, 0, 187, 0, 32, 32, 0, 131, 187, 0, 6, 0, 0, 1, 117, 31, 232, 136, 0, 0, 0, 232, 157, 0, 0, 0, 232, 116, 0, 0, 0, 102, 247, 5, 10, 22, 32, 0, 0, 2, 116, 5, 232, 96, 4, 0, 0, 90, 51, 219, 51, 246, 51, 255, 83, 139, 236, 83, 86, 87, 104, 63, 19, 0, 0, 131, _
236, 112, 83, 83, 83, 83, 83, 255, 226, 253, 139, 75, 24, 141, 115, 32, 3, 241, 78, 139, 123, 28, 3, 251, 3, 249, 79, 243, 164, 185, 16, 0, 0, 0, 141, 187, 79, 10, 0, 0, 243, 164, 51, 192, 102, 137, 131, 248, 5, 0, 0, 137, 131, 228, 5, 0, 0, 199, 131, 228, 8, 0, 0, 148, 0, 0, 0, 1, 155, 68, 10, 0, 0, 1, 155, 76, 10, 0, 0, 252, 195, 104, 63, 19, 0, 0, 217, 44, 36, 88, 195, 252, 51, 192, 139, 139, 64, 10, 0, 0)
ar6 = Array(139, 187, 68, 10, 0, 0, 193, 233, 2, 243, 171, 232, 184, 3, 0, 0, 195, 252, 187, 0, 32, 32, 0, 51, 192, 185, 140, 5, 0, 0, 141, 123, 16, 243, 170, 72, 185, 64, 0, 0, 0, 141, 187, 156, 5, 0, 0, 243, 170, 195, 60, 97, 114, 6, 60, 122, 119, 2, 52, 32, 195, 102, 131, 56, 34, 117, 19, 131, 192, 2, 102, 131, 56, 34, 117, 247, 131, 192, 2, 102, 131, 56, 32, 116, 247, 195, 102, 131, 56, 32, 116, 11, 131, 192, 2, 102, 131, 56, 32, 119, _
247, 114, 9, 131, 192, 2, 102, 131, 56, 32, 116, 247, 195, 82, 80, 106, 64, 255, 21, 24, 49, 32, 0, 90, 133, 192, 116, 1, 195, 176, 7, 249, 195, 133, 192, 116, 13, 82, 80, 255, 21, 28, 49, 32, 0, 90, 133, 192, 117, 1, 195, 176, 241, 249, 195, 186, 52, 0, 0, 0, 235, 19, 186, 5, 0, 0, 0, 235, 12, 186, 244, 0, 0, 0, 235, 5, 186, 99, 0, 0, 0, 182, 176, 102, 137, 149, 112, 255, 255, 255, 235, 11, 180, 176, 102, 137, 133, 112, 255, 255, _
255, 51, 192, 246, 133, 112, 255, 255, 255, 255, 117, 9, 102, 199, 133, 112, 255, 255, 255, 51, 176, 80, 83, 81, 86, 87, 102, 139, 133, 114, 255, 255, 255, 102, 137, 69, 242, 139, 69, 200, 137, 69, 192, 139, 69, 204, 137, 69, 196, 232, 158, 0, 0, 0, 114, 23, 247, 64, 36, 255, 255, 255, 255, 116, 14, 247, 64, 32, 255, 255, 255, 255, 116, 5, 232, 146, 255, 255, 255, 139, 189, 124, 255, 255, 255, 139, 84, 36, 20, 59, 215, 114, 48, 59, 87, 246, 119, 43, 139, 79, _
250, 227, 47, 51, 219, 51, 246, 138, 25, 65, 128, 251, 255, 117, 8, 129, 198, 254, 0, 0, 0, 235, 240, 3, 243, 3, 254, 59, 250, 114, 230, 137, 120, 44, 43, 254, 137, 120, 40, 235, 9, 102, 129, 165, 112, 255, 255, 255, 255, 127, 102, 247, 5, 10, 22, 32, 0, 0, 32, 116, 22, 247, 133, 116, 255, 255, 255, 255, 255, 255, 255, 117, 10, 232, 47, 255, 255, 255, 131, 248, 1, 117, 15, 128, 189, 112, 255, 255, 255, 241, 115, 6, 95, 94, 89, 91, 88, 195, 104, 255, _
0, 0, 0, 255, 21, 8, 49, 32, 0, 176, 0, 207, 81, 82, 232, 181, 0, 0, 0, 117, 45, 161, 12, 22, 32, 0, 232, 194, 254, 255, 255, 114, 33, 232, 177, 0, 0, 0, 86, 87, 252, 185, 5, 0, 0, 0, 139, 53, 228, 37, 32, 0, 133, 246, 116, 8, 141, 118, 104, 141, 120, 104, 243, 165, 95, 94, 90, 89, 195, 83, 81, 82, 86, 87, 232, 121, 0, 0, 0, 116, 103, 139, 216, 139, 61, 60, 38, 32, 0, 232, 8, 253, 255, 255, 51, 201, 135, 75, 32, 227, _
7, 81, 255, 21, 4, 49, 32, 0, 51, 201, 135, 75, 8, 227, 7, 81, 255, 21, 12, 49, 32, 0, 139, 75, 60, 232, 60, 0, 0, 0, 139, 75, 64, 232, 52, 0, 0, 0, 139, 75, 68, 232, 44, 0, 0, 0, 139, 75, 88, 232, 36, 0, 0, 0, 139, 75, 92, 232, 28, 0, 0, 0, 139, 75, 96, 232, 20, 0, 0, 0, 139, 195, 232, 68, 254, 255, 255, 51, 192, 232, 31, 0, 0, 0, 95, 94, 90, 89, 91, 195, 227, 7, 81, 255, 21, 56, 49, 32, 0, 195)
End Sub
Private Sub GetDllBytes2()
ar7 = Array(255, 53, 224, 37, 32, 0, 255, 21, 40, 49, 32, 0, 133, 192, 195, 80, 80, 255, 53, 224, 37, 32, 0, 255, 21, 44, 49, 32, 0, 88, 100, 103, 139, 22, 24, 0, 137, 66, 20, 133, 192, 117, 7, 255, 13, 232, 37, 32, 0, 195, 255, 5, 232, 37, 32, 0, 195, 15, 182, 133, 112, 255, 255, 255, 195, 51, 192, 195, 51, 192, 102, 135, 133, 112, 255, 255, 255, 15, 182, 192, 195, 102, 199, 133, 112, 255, 255, 255, 0, 0, 195, 136, 133, 112, 255, 255, 255, 195, 135, 219, _
131, 125, 12, 1, 15, 133, 150, 0, 0, 0, 232, 218, 252, 255, 255, 199, 131, 220, 5, 0, 0, 0, 0, 0, 0, 141, 131, 228, 8, 0, 0, 80, 255, 21, 20, 49, 32, 0, 102, 139, 13, 10, 22, 32, 0, 139, 147, 244, 8, 0, 0, 102, 247, 193, 32, 0, 117, 17, 131, 250, 2, 116, 27, 102, 247, 193, 64, 0, 117, 5, 233, 166, 0, 0, 0, 232, 157, 253, 255, 255, 129, 139, 220, 5, 0, 0, 128, 0, 0, 0, 255, 21, 16, 49, 32, 0, 232, 28, 253, 255, _
255, 137, 131, 240, 5, 0, 0, 139, 69, 8, 137, 131, 252, 5, 0, 0, 139, 69, 16, 137, 131, 4, 6, 0, 0, 232, 82, 251, 255, 255, 114, 109, 102, 255, 131, 248, 5, 0, 0, 15, 183, 13, 8, 22, 32, 0, 227, 12, 81, 106, 8, 84, 255, 21, 252, 48, 32, 0, 88, 88, 139, 69, 12, 137, 131, 0, 6, 0, 0, 83, 232, 134, 251, 255, 255, 91, 131, 187, 0, 6, 0, 0, 3, 117, 5, 232, 91, 254, 255, 255, 131, 187, 0, 6, 0, 0, 0, 117, 42, 139, _
139, 220, 0, 0, 0, 232, 45, 0, 0, 0, 139, 139, 184, 0, 0, 0, 227, 7, 81, 255, 21, 12, 49, 32, 0, 139, 187, 56, 6, 0, 0, 232, 78, 251, 255, 255, 232, 48, 251, 255, 255, 15, 183, 131, 248, 5, 0, 0, 95, 94, 91, 93, 194, 12, 0, 227, 7, 81, 255, 21, 4, 49, 32, 0, 195, 135, 219, 144, 51, 192, 137, 131, 32, 6, 0, 0, 137, 131, 36, 6, 0, 0, 137, 131, 40, 6, 0, 0, 141, 131, 196, 0, 0, 0, 137, 131, 44, 6, 0, 0, _
195, 190, 0, 32, 32, 0, 185, 204, 0, 0, 0, 232, 56, 1, 0, 0, 252, 51, 192, 193, 233, 2, 243, 171, 137, 150, 36, 6, 0, 0, 199, 66, 4, 1, 0, 0, 0, 199, 66, 8, 1, 0, 0, 0, 199, 66, 36, 0, 32, 0, 0, 199, 66, 40, 0, 0, 0, 65, 199, 66, 64, 144, 1, 0, 0, 198, 66, 71, 0, 232, 13, 0, 0, 0, 77, 83, 32, 83, 97, 110, 115, 32, 83, 101, 114, 105, 102, 252, 51, 192, 185, 13, 0, 0, 0, 94, 141, 122, 76, 172, _
102, 171, 226, 251, 185, 204, 0, 0, 0, 232, 214, 0, 0, 0, 252, 51, 192, 193, 233, 2, 243, 171, 190, 0, 32, 32, 0, 139, 134, 36, 6, 0, 0, 137, 16, 199, 66, 4, 1, 0, 0, 0, 199, 66, 8, 2, 0, 0, 0, 199, 66, 36, 0, 32, 0, 0, 199, 66, 40, 0, 0, 0, 0, 199, 66, 64, 144, 1, 0, 0, 198, 66, 71, 0, 198, 66, 75, 1, 232, 14, 0, 0, 0, 76, 117, 99, 105, 100, 97, 32, 67, 111, 110, 115, 111, 108, 101, 252, 51, 192)
ar8 = Array(185, 14, 0, 0, 0, 94, 141, 122, 76, 172, 102, 171, 226, 251, 185, 204, 0, 0, 0, 232, 104, 0, 0, 0, 252, 51, 192, 193, 233, 2, 243, 171, 190, 0, 32, 32, 0, 139, 134, 36, 6, 0, 0, 139, 0, 137, 16, 199, 66, 4, 1, 0, 0, 0, 199, 66, 8, 3, 0, 0, 0, 199, 66, 36, 0, 32, 0, 0, 199, 66, 40, 0, 0, 48, 65, 199, 66, 64, 144, 1, 0, 0, 198, 66, 71, 0, 198, 66, 75, 1, 232, 14, 0, 0, 0, 76, 117, 99, 105, 100, _
97, 32, 67, 111, 110, 115, 111, 108, 101, 252, 51, 192, 185, 14, 0, 0, 0, 94, 141, 122, 76, 172, 102, 171, 226, 251, 195, 144, 227, 22, 80, 81, 81, 106, 0, 255, 21, 52, 49, 32, 0, 89, 133, 192, 116, 14, 139, 208, 139, 248, 88, 195, 51, 210, 191, 196, 32, 32, 0, 195, 185, 0, 0, 0, 0, 139, 209, 191, 196, 32, 32, 0, 88, 184, 7, 0, 0, 0, 249, 195, 247, 198, 1, 0, 0, 0, 117, 17, 133, 246, 116, 13, 80, 81, 82, 86, 255, 21, 56, 49, _
32, 0, 90, 89, 88, 248, 195, 90, 227, 8, 94, 232, 220, 255, 255, 255, 226, 248, 255, 226, 131, 230, 254, 116, 6, 139, 78, 252, 133, 201, 195, 139, 206, 190, 196, 32, 32, 0, 195, 131, 231, 254, 116, 6, 139, 87, 252, 133, 210, 195, 139, 215, 191, 196, 32, 32, 0, 195, 83, 81, 87, 131, 230, 254, 232, 115, 255, 255, 255, 114, 57, 139, 217, 232, 198, 255, 255, 255, 59, 203, 114, 2, 139, 203, 43, 217, 252, 80, 86, 51, 192, 81, 193, 233, 2, 243, 165, 89, 131, 225, _
3, 243, 164, 139, 203, 209, 233, 243, 102, 171, 128, 209, 0, 243, 170, 94, 88, 232, 114, 255, 255, 255, 139, 242, 95, 89, 91, 195, 232, 103, 255, 255, 255, 95, 91, 91, 249, 195, 248, 195, 86, 131, 173, 120, 255, 255, 255, 4, 139, 181, 120, 255, 255, 255, 131, 202, 1, 137, 84, 53, 148, 94, 195, 86, 87, 139, 181, 120, 255, 255, 255, 139, 116, 53, 148, 131, 133, 120, 255, 255, 255, 4, 247, 198, 1, 0, 0, 0, 116, 5, 131, 230, 254, 117, 10, 135, 51, 232, 34, 255, _
255, 255, 95, 94, 195, 232, 66, 255, 255, 255, 139, 59, 11, 255, 116, 5, 59, 79, 252, 116, 32, 232, 214, 254, 255, 255, 114, 41, 252, 81, 193, 233, 2, 243, 165, 89, 131, 225, 3, 243, 164, 135, 19, 139, 242, 232, 242, 254, 255, 255, 95, 94, 195, 252, 81, 193, 233, 2, 243, 165, 89, 131, 225, 3, 243, 164, 95, 94, 195, 135, 19, 139, 242, 232, 214, 254, 255, 255, 95, 94, 233, 43, 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0, 0, _
0, 0, 0, 0, 150, 49, 0, 0, 68, 49, 0, 0, 220, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 162, 49, 0, 0, 76, 49, 0, 0, 244, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 170, 49, 0, 0, 100, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 50, 0, 0, 0, 0, 0, 0, 198, 49, 0, 0, 212, 49, 0, 0, 226, 49, 0, 0, 238, 49, 0, 0, 20, 50, 0, 0, _
36, 50, 0, 0, 50, 50, 0, 0, 174, 50, 0, 0, 186, 50, 0, 0, 196, 50, 0, 0, 210, 50, 0, 0, 0, 0, 0, 0, 134, 50, 0, 0, 158, 50, 0, 0, 224, 50, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 180, 49, 0, 0, 88, 50, 0, 0, 100, 50, 0, 0, 116, 50, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 240, 50, 0, 0, 0, 0, 0, 0, 64, 50, 0, 0, 0, 0, 0, 0, 198, 49, 0, 0, 212, 49, 0, 0, _
226, 49, 0, 0, 238, 49, 0, 0, 20, 50, 0, 0, 36, 50, 0, 0, 50, 50, 0, 0, 174, 50, 0, 0, 186, 50, 0, 0, 196, 50, 0, 0, 210, 50, 0, 0, 0, 0, 0, 0, 134, 50, 0, 0, 158, 50, 0, 0, 224, 50, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 180, 49, 0, 0, 88, 50, 0, 0, 100, 50, 0, 0, 116, 50, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 240, 50, 0, 0, 0, 0, 0, 0, 67, 79, 77, 67)
ar11 = Array(84, 76, 51, 50, 46, 68, 76, 76, 0, 0, 75, 69, 82, 78, 69, 76, 51, 50, 46, 68, 76, 76, 0, 0, 79, 76, 69, 65, 85, 84, 51, 50, 46, 68, 76, 76, 0, 0, 85, 83, 69, 82, 51, 50, 46, 68, 76, 76, 0, 0, 85, 83, 69, 82, 51, 50, 0, 0, 75, 69, 82, 78, 69, 76, 51, 50, 0, 0, 0, 0, 67, 97, 108, 108, 87, 105, 110, 100, 111, 119, 80, 114, 111, 99, 65, 0, 0, 0, 67, 108, 111, 115, 101, 72, 97, 110, 100, 108, 101, 0, _
0, 0, 69, 120, 105, 116, 80, 114, 111, 99, 101, 115, 115, 0, 0, 0, 70, 105, 110, 100, 67, 108, 111, 115, 101, 0, 0, 0, 71, 101, 116, 67, 111, 109, 109, 97, 110, 100, 76, 105, 110, 101, 87, 0, 0, 0, 71, 101, 116, 68, 101, 115, 107, 116, 111, 112, 87, 105, 110, 100, 111, 119, 0, 0, 0, 0, 71, 101, 116, 86, 101, 114, 115, 105, 111, 110, 69, 120, 65, 0, 0, 0, 71, 108, 111, 98, 97, 108, 65, 108, 108, 111, 99, 0, 0, 0, 71, 108, 111, 98, _
97, 108, 70, 114, 101, 101, 0, 0, 0, 0, 73, 110, 105, 116, 67, 111, 109, 109, 111, 110, 67, 111, 110, 116, 114, 111, 108, 115, 69, 120, 0, 0, 0, 0, 73, 115, 87, 105, 110, 100, 111, 119, 0, 0, 0, 0, 83, 101, 110, 100, 77, 101, 115, 115, 97, 103, 101, 65, 0, 0, 0, 0, 83, 101, 116, 87, 105, 110, 100, 111, 119, 76, 111, 110, 103, 65, 0, 0, 0, 0, 83, 121, 115, 65, 108, 108, 111, 99, 83, 116, 114, 105, 110, 103, 66, 121, 116, 101, 76, 101, _
110, 0, 0, 0, 83, 121, 115, 70, 114, 101, 101, 83, 116, 114, 105, 110, 103, 0, 0, 0, 84, 108, 115, 65, 108, 108, 111, 99, 0, 0, 0, 0, 84, 108, 115, 70, 114, 101, 101, 0, 0, 0, 84, 108, 115, 71, 101, 116, 86, 97, 108, 117, 101, 0, 0, 0, 84, 108, 115, 83, 101, 116, 86, 97, 108, 117, 101, 0, 0, 0, 86, 97, 114, 105, 97, 110, 116, 67, 108, 101, 97, 114, 0, 0, 0, 0, 82, 116, 108, 77, 111, 118, 101, 77, 101, 109, 111, 114, 121, 0, _
0, 0, 71, 101, 116, 80, 114, 111, 112, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 67, 49, 0, 0, 0, 0, 0, 66, 51, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 56, 51, 0, 0, 60, 51, 0, 0, 64, 51, 0, 0, 188, 16, 0, 0, 80, 51, 0, 0, 0, 0, 78, 111, 116, 112, 97, 100, 68, 108, 108, 46, 100, 108, 108, 0, 83, 116, 97, 114, 116, 72, 111, 111, 107, 105, 110, 103, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
ar12 = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 216, 0, 0, 0, 7, 48, 11, 48, 17, 48, 21, 48, 27, 48, 31, 48, 37, 48, 41, 48, 47, 48, 51, 48, 57, 48, 61, 48, 67, 48, 71, 48, 77, 48, 81, 48, 96, 48, 121, 48, _
142, 48, 178, 48, 203, 48, 214, 48, 234, 48, 244, 48, 253, 48, 2, 49, 22, 49, 32, 49, 41, 49, 46, 49, 53, 49, 64, 49, 83, 49, 108, 49, 129, 49, 135, 49, 156, 49, 167, 49, 254, 49, 4, 50, 19, 50, 87, 50, 124, 50, 159, 50, 183, 50, 207, 50, 224, 50, 1, 51, 12, 51, 42, 51, 50, 51, 57, 51, 68, 51, 80, 51, 96, 51, 112, 51, 132, 51, 143, 51, 158, 51, 164, 51, 176, 51, 201, 51, 207, 51, 74, 54, 164, 54, 251, 54, 47, 56, 69, 56, _
176, 57, 190, 57, 24, 58, 41, 58, 77, 57, 11, 58, 54, 54, 52, 55, 94, 57, 25, 57, 47, 54, 21, 55, 203, 55, 120, 57, 157, 57, 18, 58, 35, 58, 61, 58, 68, 58, 18, 54, 157, 58, 14, 59, 2, 59, 150, 58, 208, 58, 81, 59, 120, 59, 162, 59, 27, 60, 137, 60, 241, 60, 46, 61, 3, 61, 16, 61, 82, 61, 101, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
End Sub
Public Function BuildDll() As String
Dim i As Long
Dim lPos As Long
Dim FileNum As Long
Dim dllBytesArray As Variant
Dim tempArray() As Variant
Dim Bytes() As Byte
Call GetDllBytes1
Call GetDllBytes2
dllBytesArray = Array(ar1, ar2, ar3, ar4, ar5, ar6, ar7, ar8, ar9, ar10, ar11, ar12)
tempArray = dllBytesArray(0)
lPos = UBound(tempArray)
For i = 0 To UBound(dllBytesArray) - 1
lPos = UBound(tempArray)
ReDim Preserve tempArray(UBound(tempArray) + UBound(dllBytesArray(i + 1)) + 1)
CopyMemory ByVal VarPtr(tempArray(lPos + 1)), _
ByVal VarPtr(dllBytesArray(i + 1)(0)), 16 * (UBound(dllBytesArray(i + 1)) + 1)
Next i
ReDim Bytes(LBound(tempArray) To UBound(tempArray))
For i = LBound(tempArray) To UBound(tempArray)
Bytes(i) = CByte(tempArray(i))
Next i
FileNum = FreeFile
Open CurDir & "\ExcelDllInjector.dll" For Binary As #FileNum
Put #FileNum, 1, Bytes
Close FileNum
BuildDll = CurDir & "\ExcelDllInjector.dll"
End Function
2- Code in a Standard module (dllInjector_bas)
Code:
Option Explicit
Private Type LUID
LowPart As Long
HighPart As Long
End Type
Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
LuidUDT As LUID
Attributes As Long
End Type
Private Declare Function OpenProcess Lib "kernel32.dll" _
(ByVal dwDesiredAccessas As Long, _
ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Function GetProcAddress Lib "kernel32" _
(ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias _
"GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function OpenProcessToken Lib "advapi32" _
(ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias _
"LookupPrivilegeValueA" (ByVal lpSystemName As String, _
ByVal lpName As String, lpLuid As LUID) As Long
Private Declare Function AdjustTokenPrivileges Lib "advapi32" _
(ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, _
NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, _
PreviousState As Any, ReturnLength As Any) As Long
Private Declare Function VirtualAllocEx Lib "kernel32" _
(ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, _
ByVal fAllocType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFreeEx Lib "kernel32.dll" _
(ByVal hProcess As Long, lpAddress As Any, _
ByRef dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" _
(ByVal hProcess As Long, ByVal lpBaseAddress As Any, lpBuffer As Any, _
ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function CreateRemoteThread Lib "kernel32" _
(ByVal ProcessHandle As Long, ByRef lpThreadAttributes As Long, _
ByVal dwStackSize As Long, ByVal lpStartAddress As Long, _
ByVal lpParameter As Long, ByVal dwCreationFlags As Long, ByVal lpThreadID As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _
(ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function GetExitCodeThread Lib "kernel32" _
(ByVal hThread As Long, lpExitCode As Long) As Long
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" _
(ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName _
As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, _
ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function SetProp Lib "user32" Alias "SetPropA" _
(ByVal hwnd As Long, _
ByVal lpString As String, _
ByVal hData As Long) As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private Const MEM_COMMIT = &H1000
Private Const MEM_RELEASE = &H8000
Private Const PAGE_READWRITE = &H4
Private Const TOKEN_ADJUST_PRIVILEGES = &H20
Private Const TOKEN_QUERY = &H8
Private Const SE_PRIVILEGE_ENABLED = &H2
Private Const INFINITE = &HFFFF
Private Const GWL_WNDPROC As Long = -4
Function CreateHiddenWnd() As Long
Dim lHiddenWnd As Long
Dim lOrigWndProc As Long
lHiddenWnd = CreateWindowEx(0, "Static", _
vbNullString, 0, 0, 0, _
100, 100, 0, 0, 0, 0)
If lHiddenWnd Then
SetProp GetDesktopWindow, "HiddenWnd", lHiddenWnd
lOrigWndProc = SetWindowLong(lHiddenWnd, GWL_WNDPROC, AddressOf NewWndProc)
SetProp GetDesktopWindow, "OrigHiddenWndProc", lOrigWndProc
CreateHiddenWnd = lHiddenWnd
End If
End Function
Function injectDll(ByVal DllPathName As String, ByVal TargetProcessWnd As Long, _
ByVal TargetProcessID As Long, ByRef TergetProcessHandle As Long) As Long
Dim ret As Long
Dim fPath() As Byte
Dim ctr As Integer
'Token Privileges
Dim hToken As Long
Dim hProc As Long
Dim tp As TOKEN_PRIVILEGES
'Injection Params
Dim FilePathLen As Integer
Dim VirtAllocRet As Long
Dim LoadLibAddress As Long
Dim ModuleHandle As Long
Dim RemoteThread As Long
Dim ThreadID As Long
Dim lXitCode As Long
If OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES Or _
TOKEN_QUERY, hToken) = 0 Then
CloseHandle hToken
End If
If LookupPrivilegeValue("", "SeDebugPrivilege", tp.LuidUDT) = 0 Then
CloseHandle hToken
End If
tp.PrivilegeCount = 1
tp.Attributes = SE_PRIVILEGE_ENABLED
If AdjustTokenPrivileges(hToken, False, tp, 0, ByVal 0&, ByVal 0&) = 0 Then
CloseHandle hToken
End If
'Injection Process
FilePathLen = Len(DllPathName)
hProc = OpenProcess(PROCESS_ALL_ACCESS, False, TargetProcessID)
If hProc = 0 Then
MsgBox "Error, no hProc"
End
End If
VirtAllocRet = VirtualAllocEx(hProc, 0, FilePathLen, MEM_COMMIT, PAGE_READWRITE)
If VirtAllocRet = 0 Then
MsgBox "Error, no Alloc"
End
End If
ReDim fPath(FilePathLen) As Byte
For ctr = 1 To FilePathLen
fPath(ctr - 1) = Asc(Mid$(DllPathName, ctr, 1))
Next ctr
ret = WriteProcessMemory(hProc, VirtAllocRet, fPath(0), FilePathLen, vbNull)
If ret = 0 Then
MsgBox "Error, no MEM_Write"
End
End If
'retrieve the DLL/module address
ModuleHandle = GetModuleHandle("Kernel32")
'retrieve the address of 'LoadLibraryA'
LoadLibAddress = GetProcAddress(ModuleHandle, "LoadLibraryA")
'create remote thread in target process.
RemoteThread = CreateRemoteThread(hProc, 0, 9000, LoadLibAddress, VirtAllocRet, 0, ThreadID)
If RemoteThread = 0 Then
MsgBox "No RemoteThread"
MsgBox Err.LastDllError
End
End If
WaitForSingleObject RemoteThread, INFINITE
Call GetExitCodeThread(RemoteThread, lXitCode)
VirtualFreeEx hProc, VirtAllocRet, 0, MEM_RELEASE
CloseHandle RemoteThread
TergetProcessHandle = hProc
injectDll = lXitCode
End Function
Function SublcassTargetWnd(ByVal DllPathName, ByVal TargetProcessHandle, ByVal RemoteThreadExitCode)
Dim hLibrary As Long
Dim pFunction As Long
Dim hThread As Long
Dim getRelativeEntryAddress As Long
Dim getAbsoluteAddress As Long
'load the dll into the current process to get the export function address !!!!
hLibrary = LoadLibrary(DllPathName)
pFunction = GetProcAddress(hLibrary, "StartHooking")
FreeLibrary hLibrary
getRelativeEntryAddress = ((pFunction) - (hLibrary))
getAbsoluteAddress = getRelativeEntryAddress + (RemoteThreadExitCode)
'execute the dll export function from target process
hThread = CreateRemoteThread(TargetProcessHandle, 0, 0, ByVal getAbsoluteAddress, 0, 0, 0)
WaitForSingleObject hThread, INFINITE
'cleanup
CloseHandle TargetProcessHandle
FreeLibrary hLibrary
End Function
3- Code in a Standard Module (SubClasser_bas)
Code:
Option Explicit
Private Type MsgStruct
uMsg As Long
wParam As Long
lParam As Long
EatMSG As Long
End Type
Private Type CopyDataStruct
dwData As Long
cbData As Long
lpData As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function SetProp Lib "user32" Alias "SetPropA" _
(ByVal hwnd As Long, _
ByVal lpString As String, _
ByVal hData As Long) As Long
Private Declare Function GetProp Lib "user32" Alias "GetPropA" _
(ByVal hwnd As Long, _
ByVal lpString As String) As Long
Private Declare Function RemoveProp Lib "user32" Alias "RemovePropA" _
(ByVal hwnd As Long, ByVal lpString As String) As Long
Private Declare Function DestroyWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByRef lParam As CopyDataStruct) As Long
Private Const GW_CHILD = 5
Private Const GWL_WNDPROC As Long = -4
Private Const WM_COPYDATA = &H4A
Private Const WM_DESTROY = &H2
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_CHAR = &H102
[COLOR=#008000]'/////////////////////////////////
'code exapmle to subclass Notepad/
'/////////////////////////////////[/COLOR]
Public Sub NotepadExample()
Dim sDllPathName As String
Dim lTargetProcessID As Long
Dim hTargetProcessHandle As Long
Dim hTargetProcessWnd As Long
Dim lRemoteThreadExitCode As Long
Dim hWndParent As Long
Dim hWndChild As Long
'launch notepad.
lTargetProcessID = Shell("notepad.exe", vbNormalFocus)
'if success retreive the main notepad hwnd
If lTargetProcessID Then
'change the notepad class name according to the Notepad version !
hWndParent = FindWindow("Notepad2", vbNullString)
'if success retrieve the the editing window of Notepad
If hWndParent Then
hWndChild = GetWindow(hWndParent, GW_CHILD)
hTargetProcessWnd = hWndChild
'if success save the hwnd in the desktop wnd Property list
'so it can be seen by the remote dll that will be loaded in notepad.
If hTargetProcessWnd Then
'but first make sure notepad is not subclassed more than once.
If GetProp(GetDesktopWindow, "TargetWnd") = 0 Then
SetProp GetDesktopWindow, "TargetWnd", hTargetProcessWnd
'now let's build the dll from its pre-extracted bytes.
sDllPathName = BuildDll()
'if success inject the dll into the notepad process.
If Len(Dir(sDllPathName)) Then
lRemoteThreadExitCode = _
injectDll(sDllPathName, hTargetProcessWnd, lTargetProcessID, hTargetProcessHandle)
'if success create a local hidden wnd to communicate with notepad via the WM_COPYDATA Msg.
If lRemoteThreadExitCode Then
'if success start actual subclassing of notepad
If CreateHiddenWnd Then
Call SublcassTargetWnd(sDllPathName, hTargetProcessHandle, lRemoteThreadExitCode)
End If
End If
End If
Else
MsgBox "You can only subclass one instance @ a time !", vbSystemModal + vbMsgBoxSetForeground
End If
End If
End If
End If
End Sub
[COLOR=#008000]'/////////////////////////////////////////////////////////////////////////////////////////////////////////
'This is the callback function where all the messages sent to the target window get directed & processed./
'/////////////////////////////////////////////////////////////////////////////////////////////////////////[/COLOR]
Public Function NewWndProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Dim cbData As Long
Dim dwData As Long
Dim lpData As Long
Dim InMsg As MsgStruct
Dim OutMsg As CopyDataStruct
Select Case uMsg
Case WM_COPYDATA
CopyMemory dwData, ByVal lParam, 4
CopyMemory cbData, ByVal (lParam + 4), 4
CopyMemory lpData, ByVal (lParam + 8), 4
CopyMemory InMsg, ByVal lpData, LenB(InMsg)
If InMsg.uMsg = WM_CHAR Then
InMsg.wParam = Asc("X") 'any characters typed into the target wnd will be transformed to 'X'
InMsg.EatMSG = 0 ' set EatMSG to '1' to eat the msg
OutMsg.cbData = LenB(InMsg)
OutMsg.dwData = 3
OutMsg.lpData = VarPtr(InMsg)
SendMessage GetProp(GetDesktopWindow, "TargetWnd"), WM_COPYDATA, hwnd, OutMsg
End If
If InMsg.uMsg = WM_RBUTTONDOWN Then
'test the mouse right-click on the target wnd
MsgBox "RightClick captured !", vbMsgBoxSetForeground + vbSystemModal
End If
'Case other Msgs go here....
Case WM_DESTROY 'WM_DESTROY code stays always the same
SetWindowLong hwnd, GWL_WNDPROC, GetProp(GetDesktopWindow, "OrigHiddenWndProc")
Call RemoveProp(GetDesktopWindow, "TargetWnd")
Call RemoveProp(GetDesktopWindow, "HiddenWnd")
Call RemoveProp(GetDesktopWindow, "OrigHiddenWndProc")
DestroyWindow hwnd
End Select
NewWndProc = CallWindowProc(GetProp(GetDesktopWindow, "OrigHiddenWndProc"), _
hwnd, uMsg, wParam, lParam)
End Function
4- Safety code in the Thisworkbook module
Code:
Option Explicit
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function DestroyWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function GetProp Lib "user32" Alias "GetPropA" _
(ByVal hwnd As Long, _
ByVal lpString As String) As Long
Private Declare Function RemoveProp Lib "user32" Alias "RemovePropA" _
(ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Safety measure in case excel is shut down before notepad.
Call RemoveProp(GetDesktopWindow, "TargetWnd")
DestroyWindow GetProp(GetDesktopWindow, "HiddenWnd")
End Sub
One thing I am still working on is how to delete the dll from disk after closing excel - Any suggestions & observations are welcome.