获取 VBA/访问源代码

发布于 2024-11-25 01:15:44 字数 413 浏览 4 评论 0原文

我正在用 C# 重写旧版访问/VBA 应用程序。虽然我作为一名 VBA 程序员受到限制,但我的印象是代码经过最低限度的编译并且几乎作为脚本运行?显然没有安全性/VBA,您只需点击 alt + f11 即可获取源代码有没有好的方法来反编译/获取此代码?

所以我尝试了这个: http://forums.databasejournal.com/showthread.php?t= 34222

似乎是关于如何反编译 .mdb 文件。

然而,该程序很快就重新编译了自己——或者至少在左下状态栏中说它正在重新编译自己。有什么想法吗?

I'm rewriting a legacy access / VBA application in C#. While I am limited as a VBA programmer I am under the impression that the code is minimally compiled and runs almost as a script ? Obviously no security / VBA you can just hit alt + f11 to get at the source code is there a good way to decompile / get at this code?

So I tried this: http://forums.databasejournal.com/showthread.php?t=34222

which appears to be about how to decompile .mdb files.

However the program quickly recompiled itself - or at least says it is recompiling itself in the lower left status bar. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

感情洁癖 2024-12-02 01:15:44

这里有一些建议(其中一些是我在上面的评论中重复的):

  • Alt-F11 不是我打开 VBE 的常用方法,因为我通常想要进入立即窗口。请尝试使用 Ctrl-G。

  • 如果 Alt-F11 和 Ctrl-G 都无法打开 VBE,则数据库的 AllowBypassKey 属性可能已更改为 False。要获取更改此设置的代码,请在 Access 帮助文件中搜索AllowBypassKey(在 VBE 中,从帮助菜单中搜索“AllowBypassKey”)。但是,如果AllowBypassKey 关闭,您将无法在您尝试调查的数据库中运行代码,因此您可以运行以下代码:

//

  On Error GoTo Change_Err
    Dim db As DAO.Database
    Dim prp As Variant
    Const conPropNotFoundError = 3270

    Set db = DBEngine.OpenDatabase("C:\Databases\MyDatabase.mdb")
    db.Properties("AllowBypassProperty") = True

  exitRoutine:
    If Not (db Is Nothing) Then
       db.Close
       Set db = Nothing
    End If
    Exit Sub

  errHandler:
    If Err = conPropNotFoundError Then    ' Property not found.
       ' do nothing and exit
       Resume exitRoutine
    End If

然后您应该能够在按住 SHIFT 时打开数据库key(绕过任何定义的启动例程,这些例程可能会关闭对 VBE 的访问)。

  • 如果文件是 MDE,则没有源代码。您可以通过检查此属性来确定它是否是 MDE:

    ?CurrentDB.Properties("MDE")

如果它是 MDE(文件可以有任何扩展名),这将返回“T”。如果不是 MDE,则会抛出错误(因为该属性不存在)。

  • 其他需要检查的事情可能是有多少个模块。如果您打开了数据库并且可以进入立即窗口 (Ctrl-G),那么这将告诉您是否有任何模块:

//

  ?CurrentProject.AllModules.Count
  • 您还可以通过打开VBE 中的对象浏览器 (F2) 并在顶部的下拉列表中选择项目名称(默认情况下会显示“”

  • 最后,您可能认为它可以受到 Jet ULS 的保护,但从 Access 2000 开始,这不太可能,因为除了VBA 项目上的密码可用(即,它不再包含在 Jet ULS 中),我希望如果它受密码保护,系统会在某处提示您输入密码,因此您已经知道了。 最后,您可能认为它可以受到 Jet ULS 的保护,但从 Access 2000 开始,这种

Here are some suggestions (some of which I'm repeating from comments I've made above):

  • Alt-F11 is not my usual method of opening the VBE, because I usually want to go to the Immediate Windows. Try Ctrl-G, instead.

  • If both Alt-F11 and Ctrl-G fail to open the VBE, then perhaps the AllowBypassKey property of the database has been changed to False. To get code to change this, search the Access help file for AllowBypassKey (in the VBE, from the help menu, search for "AllowBypassKey"). However, you won't be able to run the code within the database you're trying to investigate if AllowBypassKey is turned OFF, so you can run this code:

//

  On Error GoTo Change_Err
    Dim db As DAO.Database
    Dim prp As Variant
    Const conPropNotFoundError = 3270

    Set db = DBEngine.OpenDatabase("C:\Databases\MyDatabase.mdb")
    db.Properties("AllowBypassProperty") = True

  exitRoutine:
    If Not (db Is Nothing) Then
       db.Close
       Set db = Nothing
    End If
    Exit Sub

  errHandler:
    If Err = conPropNotFoundError Then    ' Property not found.
       ' do nothing and exit
       Resume exitRoutine
    End If

Then you should be able to open the database when holding down the SHIFT key (which bypasses any defined startup routines, which might have been shutting off access to the VBE).

  • If the file is an MDE, there is no source code. You can find out if it's an MDE by checking this property:

    ?CurrentDB.Properties("MDE")

If it's an MDE (the file can have any extension), this will return "T". If it's not an MDE, it will throw an error (because the property doesn't exist).

  • Other things to check might be how many modules there are. If you have the database open and can get to the Immediate Windows (Ctrl-G), then this will tell you if there are any modules:

//

  ?CurrentProject.AllModules.Count
  • You also might be able to see what's in the database by opening up the Object Browser in the VBE (F2) and selecting the project name in the dropdown at the top (it will say "" by default

  • Last of all, you may think that it could be protected by Jet ULS, but starting with Access 2000, that's not a big possible, as there's nothing but a password on the VBA project available (i.e., it's no longer covered under Jet ULS). I would expect that if it were password-protected, you'd be prompted for the password somewhere along the line, so you'd already know that.

暮年 2024-12-02 01:15:44

如果它是 .mde 你就不走运了。您需要获取包含源 VBA 代码的 .mdb,该代码经过编译以创建 .mde

If it's an .mde you are out of luck. You need to get hold of the .mdb containing the source VBA code that was compiled to create the .mde

万劫不复 2024-12-02 01:15:44
  • 如何查看源代码(.mdb 文件)
    1. 选择文件
    2. 按住“Shift”键
    3. 然后双击该文件,不要释放“shift”键
  • HOW TO VIEW SOURCE CODE (.mdb FILE)
    1. Select the file
    2. Hold the 'shift' key
    3. Then double click the file without releasing the 'shift' key
潜移默化 2024-12-02 01:15:44
  1. 导航到计算机上的程序文件夹。

  2. 打开 MS Office 文件夹

  3. 导航到 MSAccess.exe 并创建它的快捷方式。

  4. 将快捷方式移动到数据库所在的位置(让生活更轻松,您需要对每个要反编译的数据库执行此操作)。

  5. (可选)将快捷方式重命名为“我的数据库的反编译器,其名称为...”,这样您就知道打开它会破坏您编译的代码

  6. 右键单击快捷方式以查看其属性。在快捷方式属性对话框的“目标”字段中,您将看到类似“C:\Program Files\Microsoft Office\Office\MSACCESS.EXE”的内容

  7. 在目标字段中,使用右箭头指向该快捷方式的末尾路径名,键入一个空格,然后在引号中键入(或粘贴)要反编译的 MS Access 文件位置的完整路径名(最简单的方法是从文件所在窗口的地址栏复制,如果您有地址栏

  8. 仍然在“目标”字段中,键入一个空格,然后不带引号,键入 /decompile

  9. 单击“确定”接受更改并关闭对话框。

  10. 按住 Shift 键并保持按下。

  11. 摆动你的耳朵

  12. 双击快捷方式。

  13. 转到数据库中的任何模块。

  1. Navigate to the Program Folders on your computer.

  2. Open the MS Office Folder

  3. Navigate to MSAccess.exe and make a shortcut of it.

  4. Move the shortcut to where your database resides (makes life easier and you'll need to do this for each database to decompile).

  5. (optional) Rename the shortcut to something like "decompiler for my database whose name is...." so you know that opening it blows away your compiled code

  6. Right-click on the shortcut to view its properties. In the Target field of the properties dialog box for the shortcut you'll see something like "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"

  7. In the target field, right-arrow to the end of the pathname, type a space, and then, in quotes, type (or paste) the full pathname of the location of your MS Access file to decompile (easiest way is to copy from the address bar on your window where the file resides, if you have the address bar showing).

  8. Still in the Target field, type a space, and then with no quotes, type /decompile

  9. Click OK to accept the changes and to close the dialog box.

  10. Hold the Shift key down and keep it down.

  11. Wiggle your ears

  12. Double-click on the shortcut.

  13. Go to any module in your database.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文